开发者

FastReport processing click on the field

开发者 https://www.devze.com 2023-04-09 04:55 出处:网络
The question 开发者_StackOverflow社区is how to handle a click on the field and call the procedure from the main program.Yes, it is. I don\'t know what you mean with the field and what version of FastR

The question 开发者_StackOverflow社区is how to handle a click on the field and call the procedure from the main program.


Yes, it is. I don't know what you mean with the field and what version of FastReport you are using, but I'll try to show you the principle of interaction with the report objects (this can be done for any of the report objects in a preview window). However the TfrxReport.OnClickObject event differs with FastReport versions so depending on what version you are using this might differ little bit.

The following example (written with version 4.12) interacts with Memo1, what is the Text object (TfrxMemoView) placed in design time on the report frxReport1. The rest of what you need is to write the code for OnClickObject event handler in your main form.

procedure TForm1.frxReport1ClickObject(Sender: TfrxView;
  Button: TMouseButton; Shift: TShiftState; var Modified: Boolean);
begin
  // comparing names is not so efficient, so for many controls I would use
  // rather Sender.Tag and set the Tag property at report design time and
  // use case Sender.Tag of construction

  if Sender.Name = 'Memo1' then // is the Sender my Memo1 text object ?
  begin
    if fsBold in (Sender as TfrxMemoView).Font.Style then // is Memo1 font bold ?
    begin
      (Sender as TfrxMemoView).Font.Style := []; // then set it to default
      ShowMessage('You just set memo text font to default'); // display message
    end
    else
    begin
      (Sender as TfrxMemoView).Font.Style := [fsBold]; // else set it to bold
      ShowMessage('You just emphased your memo text font'); // display message
    end;

    Modified := True; // setting Modified to True causes the report to refresh
  end;
end;


If you need put another text, try one option:

(Sender as TfrxMemoView).Text := 'Hi friend';

or:

TfrxMemoView(Sender).Text := 'Hi friend';
0

精彩评论

暂无评论...
验证码 换一张
取 消