How to hide a form at runtime

Stimulsoft Reports.NET discussion
Post Reply
JamieD
Posts: 2
Joined: Fri Jan 27, 2012 12:38 pm

How to hide a form at runtime

Post by JamieD »

Hello

We have created a report that has a simple form that allows the user to pick a date range then click Go (set as default and DialogResult.OK) however we would like to be able to disable the form at runtime so that the default values in the date fields are used I have tried adding

Code: Select all

this.Pages.Remove(frmOptions);
to the constructor, and that has the desired effect of removing the form however the main data band doesn't correctly bind to the data when doing this and so only a group header is printed.
Next I attempted to set the page to be Enabled = false; however that doesn't seem to do anything and the form was still rendered.

Additionally I tried adding a method to the form to immediately close the form but calling

Code: Select all

Close();
would stop the report from rendering at all, the other change I have tried is using

Code: Select all

btnGo.Control.PerformClick();
to simulate a user click once the form had loaded but it seems to have no effect.

Is there a way to disable a form before it is shown?

Thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

How to hide a form at runtime

Post by Alex K. »

Hello,

Please try to use the following code:

Code: Select all

StiForm frm = report.GetComponents()["Form1"] as StiForm;
frm.Visible = false;
Thank you.
JamieD
Posts: 2
Joined: Fri Jan 27, 2012 12:38 pm

How to hide a form at runtime

Post by JamieD »

Thank you Aleksey that worked perfectly.
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

How to hide a form at runtime

Post by Andrew »

Hello,

Great!

Have a good day!
Post Reply