Monday, May 07, 2007

OnLoaded Event

I was doing a Windows Application and i wanted to raise an event which should be raised after the Form is loaded , or in other words the "OnLoaded" event.

Couldn't find any straightforward solution and finally had to depend on following. Can anyone suggest anything better ?


private void Form1_Load(object sender, System.EventArgs e)
{
Application.Idle +=new EventHandler(Form1_Loaded);
MessageBox.Show("loading");
}


private void Form1_Loaded(object sender, EventArgs e)
{
MessageBox.Show("loaded");
Application.Idle -=new EventHandler(Form1_Loaded);
}