Page 1 of 1

Hidding certain controls

Posted: Tue Jan 15, 2008 8:31 am
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.

Hidding certain controls

Posted: Tue Jan 15, 2008 9:16 am
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.

Hidding certain controls

Posted: Thu Jan 17, 2008 9:31 am
by fkmfkm
Edward,

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

Thank you.

Hidding certain controls

Posted: Thu Jan 17, 2008 11:21 am
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.


Hidding certain controls

Posted: Thu Jan 17, 2008 7:44 pm
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 ?

Hidding certain controls

Posted: Fri Jan 18, 2008 3:51 am
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.

Hidding certain controls

Posted: Fri Jan 18, 2008 9:14 am
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.

Hidding certain controls

Posted: Fri Jan 18, 2008 9:47 am
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.