If there is indeed a bug, then GlynA has a good solution. It is possible that the show then hide operation will cause the form to flash on the screen, and that could be annoying. If that happens, then prior to showing the form for the first time you might try setting the Left or Top properties to a value that makes the form appear somewhere off the screen. But, don't forget to set the Left or Top property back to a more normal setting before you call ShowDialog().
Another solution might be to create a public method on the form that calls the Form1_Load() event method directly. Something like:
Code:
public void FireForm_Load() {
Form1_Load();
}
Then, if you want to make sure that the load event only gets executed once for each time the form is instantiated, put some code like this inside the load event routine:
Code:
if (!this.loadEventFired) {
// event code goes here
..
this.loadEventFired = true;
}
and make sure you create a private boolean class variable called "loadEventFired".
So, when you call the ShowDialog() method, just add a call to FireForm_Load(), like this:
Code:
ClassLibrary1.Form1 window=new ClassLibrary1.Form1();
window.FireForm_Load();
window.ShowDialog();
This solution would also prevent the Form1_Load() event code from being run more than once if the .Net bug was fixed in the future.