Run a method after a form appears

  • Thread starter Thread starter Stew
  • Start date Start date
S

Stew

Hello,

I have a form, with a progress bar, which execute some operations like
checking update before launching another form.

I want update this progress bar but I don't know how launch my method
after the form appears on screen. I tried all events but they launched
my method before the form appears. I believe in .Net framework, there
is an event on Form show.

How can I do it? I am using compact framework 2.0 beta.

Example

public FormWelcome()
{
InitializeComponent();
CheckUpdate() ;
}

Thanx for your help.

Steve
 
Hello Alex,

Thx for your reply but the form appears on screen only after load
event. It's the same problem.

Steve
 
You might want to run your "method" on a different thread. Don't forget to
use Control.Invoke when updating progress bar from a separate thread.

HTH... Alex
 
Option 1:
Try calling Application.DoEvents(); at the end of your Form_Load event. Then call your method.

Option 2:
Try using the Validated event. This triggers after a form has been painted I believe.

Option 3:
You could start a timer in the load event (or instantiation) that checks a flag. When the flag becomes true, then the timer stops and triggers your method. Flag defaults to false, and set to true at the end of the Form_Loaded event. You may even put a small delay after the flag is true. This is a very messy way to handle it though.

*****************************************
* A copy of the whole thread can be found at:
* http://www.dotnetmonster.com/Uwe/Forum.aspx/dotnet-compact-framework/9104
*
* Report spam or abuse by clicking the following URL:
* http://www.dotnetmonster.com/Uwe/Abuse.aspx?aid=3c6fd90b625446c686d8a0674d411da5
*****************************************
 
Back
Top