Hidding certain controls

Stimulsoft Reports.NET discussion
Post Reply
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Hidding certain controls

Post by fkmfkm »

Is is possbile to hide certain components on the report based on certain passed in indicators ? HOw should I do it ?

Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Hidding certain controls

Post by Edward »

Yes, it is possible.

Please do the following:

Describe a variable of the bool type in the Dictionary of the report.

In the BeforePrintEvent of the page please write something like this:

Code: Select all

MyComponent.Enabled = MyVariable1;
Then from your application this MyVariable can be set as follows:

Code: Select all

report.Dictionary.Variables["MyVariable1"].ValueObject = false;
Thank you.
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Hidding certain controls

Post by fkmfkm »

Edward,

How do I get to the page events ? I have never done any event in reports before.

Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Hidding certain controls

Post by Edward »

Please do the following steps:

Click on the report page in any free from the components space. Then select a Property Editor (you can do it also with F4).
Press the button in the top of the Property Editor with yellow lightning image on it to access the Page events.
And in the BeforePrintEvent you may write the code.

Please see the report attached.

Also the following way is available:

Code: Select all

StiReport report = new StiReport();
report.Load("ReportParameter.mrt");
(report.GetComponents()["Text1"] as StiText).Enabled = false;
report.Show();
Thank you.

Attachments
28.ReportParameter.zip
(1.85 KiB) Downloaded 171 times
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Hidding certain controls

Post by fkmfkm »

Edward,

I got it...

But when i use this

rep.Dictionary.Variables("ShowPrice").ValueObject = False

it does not work.

So I use this

rep("ShowPrice") = False

And it works. :) How Come ?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Hidding certain controls

Post by Edward »

The first way affects on the report template before compilation, but the second one is applied to the compiled report.

The second way which is used by you is more efficient because the report have to be already compiled.

The first way applied to the report template and if the report had been compiled then changes of the template would not change the report output.

So if your report have been compiled, then only rep("ShowPrice") = False would work.

Thank you.
fkmfkm
Posts: 181
Joined: Thu Jul 05, 2007 11:26 pm
Location: Kuala Lumpur

Hidding certain controls

Post by fkmfkm »

Thanks for the explanation.

One more question. Is it possble to group a number of controls so I can just write one line of code to hide them all at once ?

Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Hidding certain controls

Post by Edward »

If possible, you can place them inside the Container component and hide it.

Also you can use Tag property of the components and then just check the collection of all Components for deciding to hide them or not.

Thank you.
Post Reply