Execute code after form is fully loaded.

  • Thread starter Thread starter David D Webb
  • Start date Start date
D

David D Webb

I have a form that I am using as a dialog box. It pops up and provides
status info to the user while a process is going on. So, I want the form to
completely show, then begin processing of a method within that form class.
But there isn't a Loaded event - just Load. Then I want the form to close
automatically after the form is done processing. I can't get the form to
show completely before the code starts running, and sometimes this.Close()
is not closing the form.

Any suggestions?
Dave
 
David,

Just add a timer to that form with a low interval, enable it at the end of
your load event so it launches your function. Disable the timer again
inmediately after getting control in your function and that's it. From there
you can close your form.
 
What happens if in Load event you call Application.DoEvents before doing
your processing?
 
Thanks, that did the trick. I used the following code in the load event and
it worked perfectly:

Application.DoEvents();
Cursor.Current = Cursors.WaitCursor;

BeginDownload(); // Custom class method.

this.Close();

-Dave
 
Back
Top