The “ConfigurationRuntimeForm” object exists only after the form completely loads. If I place this code in the On Loaded event, I get an “object not set to an instance of an object”. However, as a test, if I place the code in a button, it finds it.
string forms = “”;
foreach (var f in System.Windows.Forms.Application.OpenForms)
{
forms += f.ToString() + “\n”;
}
MessageBox.Show(forms);
Inside On Loaded event:
Inside Button click event:
You can see the ConfigurationRuntimeForm at the bottom which doesn’t exist in the On Loaded list.
Any other way to set this after knowing when the object is available?
The “ConfigurationRuntimeForm” object exists only after the form completely loads. If I place this code in the On Loaded event, I get an “object not set to an instance of an object”. However, as a test, if I place the code in a button, it finds it.
string forms = “”;
foreach (var f in System.Windows.Forms.Application.OpenForms)
{
forms += f.ToString() + “\n”;
}
MessageBox.Show(forms);
Inside On Loaded event:
Inside Button click event:
You can see the ConfigurationRuntimeForm at the bottom which doesn’t exist in the On Loaded list.
Any other way to set this after knowing when the object is available?
It’s because the FormsCollection doesn’t contain “ConfigurationRuntimeForm” object at the point On Loaded fires. However, if I run this code in a button click, it works.
Not sure why the “ConfigurationRuntimeForm” object doesn’t exist when the event fires.
This code will not work in the On Loaded event of the configurator and should be just in the Page On Loaded. Having it only in the Page On Loaded will do what you want. If you remove all code from your On Loaded of the configurator does this then pass the syntax check?
So this is interesting. In Page 2 On Page Loaded this works which is where I have used it. For Page 1 it does not work. I am checking to see if something else is going on.
If you dump this code in Page1 On Loaded event and Page2 On Loaded event, you can see that “ConfigurationRuntimeForm” object doesn’t exist (at the bottom of the messagebox) on Page 1, but does on Page 2.
string forms = “”;
foreach (var f in System.Windows.Forms.Application.OpenForms)
{
forms += f.ToString() + “\n”;
}
MessageBox.Show(forms);