Page 1 of 1

How to hide a form at runtime

Posted: Fri Jan 27, 2012 12:46 pm
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

How to hide a form at runtime

Posted: Mon Jan 30, 2012 2:25 am
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.

How to hide a form at runtime

Posted: Mon Jan 30, 2012 7:21 am
by JamieD
Thank you Aleksey that worked perfectly.

How to hide a form at runtime

Posted: Tue Jan 31, 2012 1:30 am
by Andrew
Hello,

Great!

Have a good day!