FastReport处理点击字段

发布于 2024-12-06 20:15:21 字数 31 浏览 0 评论 0原文

问题是如何处理字段上的单击并从主程序调用该过程。

The question is how to handle a click on the field and call the procedure from the main program.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

失去的东西太少 2024-12-13 20:15:21

是的。我不知道您对该字段的含义以及您使用的 FastReport 版本是什么,但我将尝试向您展示与报表对象交互的原理(这可以对预览中的任何报表对象进行)窗户)。但是,TfrxReport.OnClickObject 事件因 FastReport 版本而异,因此根据您使用的版本,该事件可能会略有不同。

下面的例子(用4.12版本编写)与Memo1交互,设计时放在报表frxReport1上的Text对象(TfrxMemoView)是什么。您需要做的其余工作是在主窗体中编写 OnClickObject 事件处理程序的代码。

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;

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;
你在我安 2024-12-13 20:15:21

如果您需要输入其他文本,请尝试一个选项:

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

或:

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

If you need put another text, try one option:

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

or:

TfrxMemoView(Sender).Text := 'Hi friend';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文