问题是如何处理对该字段的单击并从主程序调用该过程。
3400 次
2 回答
2
是的。我不知道您对字段的含义以及您使用的是什么版本的 FastReport,但我会尝试向您展示与报表对象交互的原理(这可以在预览中对任何报表对象进行窗户)。然而,该TfrxReport.OnClickObject
事件与 FastReport 版本不同,因此取决于您使用的版本,这可能会有所不同。
以下示例(使用 4.12 版编写)与报表交互,设计时放置的Memo1
内容是什么。剩下的就是在主窗体中编写事件处理程序的代码。Text object (TfrxMemoView)
frxReport1
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;
于 2011-09-27T20:53:25.390 回答
0
如果您需要输入其他文本,请尝试一个选项:
(Sender as TfrxMemoView).Text := 'Hi friend';
或者:
TfrxMemoView(Sender).Text := 'Hi friend';
于 2013-06-18T14:45:39.720 回答