fastreport Hide Elements in DataBand depending on Data

喜欢而已 提交于 2019-12-11 06:08:38

问题


In a Report designed with fastreport we want to hide or Show an Image Object in the Data Band Depending on the given Data (e.g. a Boolean Property).

I know that I can set the Visibilty of Objects with C# by Adressing the Object by its Name, but inside a DataBand the Object with the Name is there multiple times.


回答1:


If I understand your question correctly, next approach may help. I often use this approach, when I want to manipulate objects in databand depending on data. Just put your logic in OnBeforePrint event for given band in FastReport editor. Every object (including TfrxPictureView) has a name in FastReport editor and you can access it by this name.

Next example is working:

Pascal Script

procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
   Picture1.Visible := (<reportdataset."YourField"> = 'YourValue');                                                 
end;

C++ Script

void MasterData1OnBeforePrint(TfrxComponent Sender)
{
   Picture1.Visible = (<reportdataset."YourField"> == "YourValue");                                                 
}

C# Script

void MasterData1OnBeforePrint(object sender, EventArgs e)
{
   Picture1.Visible = ((string)Report.GetColumnValue("reportdataset.YourField") == "YourValue");                                                 
}


来源:https://stackoverflow.com/questions/53591235/fastreport-hide-elements-in-databand-depending-on-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!