Ways to call code after Form OnLoad is finished?
Posted on 2005-05-17
I have 2 forms, a Login window and a mainform. However it isn't the standard Login -> Mainform flow. When the program starts, the Mainform appears (with all functionality disabled) and the Login window appears ontop of the MainForm. When the user logs in, the Login form goes away, and the Mainform is enabled and active.
Currently, the way Im doing this, in Mainform_Onload it starts a Timer set to 100. When the timer pulses, it disables the timer and creates the Login and does ShowDialog(). If they enter correct login information, the Login form goes away and then Mainform is enabled.
I'm using a timer because if I create a Login instance during Mainform_Onload and ShowDialog() while still in the Onload, the Login page shows, but the Mainform never gets painted until the user is done with the Login screen.
Is there a way to do what I am doing *without* having to rely on a Timer? So far nothing I've done has gotten Mainform to show before it finishes the OnLoad method, and the only way I've found to delay the Login page until that has been done is by using a Timer.