Windows form, events?

  • Thread starter Thread starter Iwan Petrow
  • Start date Start date
I

Iwan Petrow

Hi,

I have a windows form and I want after the form is loaded (the form is
shown on the screen) to show a dialog. This dialog have to be shown
only once when a start the form. Which event I could use?

Thanks.
 
You could use the Load event, or OnLoad override, and "force" the Form to be
shown by calling "this.Show()" and then display your other Form after that.
Alternatively, if that doesn't work in your case then you could use the
Activated event, or the OnActivated override, with a boolean flag as shown
below.

private bool doOnceComplete = false;

protected override void OnActivated(System.EventArgs e)
{
if (!this.doOnceComplete)
{
Form2 f = new Form2();
f.Show();
this.doOnceComplete = true;
}
base.OnActivated(e);
}
 
Back
Top