Events in a form

  • Thread starter Thread starter Phil
  • Start date Start date
P

Phil

Hello

Can anybody tell me which events are fired immediately after a form is
displayed i.e. appears on screen?

Ta

Phil
 
Phil,

When a form is hidden or shown, the VisibleChanged event should fire.
When a form is shown for the first time, the Load event should fire.

Hope this helps.
 
Thank you Nicholas for your prompt reply.

Unfortunately, after trying both methods it doesn't solve the problem I
have.

What I'm trying to do is to display a Modal dialog immediately after the
main form has become visible. If I put the modal dialog call in either Load
or Visible changed, the dialog appears but the calling form doesn not appear
until after it has been closed.

Can you, or others, suggest how I can do this?

Phil


Nicholas Paldino said:
Phil,

When a form is hidden or shown, the VisibleChanged event should fire.
When a form is shown for the first time, the Load event should fire.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Phil said:
Hello

Can anybody tell me which events are fired immediately after a form is
displayed i.e. appears on screen?

Ta

Phil
 
Hello

Can anybody tell me which events are fired immediately after a form is
displayed i.e. appears on screen?

That's the Activated event. Be careful, this event is raised each time the
form is shown on the screen, not only the first time it is shown (for
example, after being hidden by another form and then brough back to the
front again, the Activated event will be fired). So take care of removing
the event handler when you catch this event in order for it not to be
catched again.
 
Hello Elp

Thank you. That did it!

Just as a matter of interest, is there a way to override Show()?

Phil
 
Hello Elp

Thank you. That did it!

Just as a matter of interest, is there a way to override Show()?

I tried to do it once but i think that it didn't work. Forgot why. However,
you can redefine it like that:

public new void Show()
{
base.Show();
// Your extra code here
}
 
Thanks Elp

Elp said:
I tried to do it once but i think that it didn't work. Forgot why.
However,
you can redefine it like that:

public new void Show()
{
base.Show();
// Your extra code here
}
 
Hi Phil,
Thank you Nicholas for your prompt reply.

Unfortunately, after trying both methods it doesn't solve the problem I
have.

What I'm trying to do is to display a Modal dialog immediately after the
main form has become visible. If I put the modal dialog call in either Load
or Visible changed, the dialog appears but the calling form doesn not appear
until after it has been closed.

Can you, or others, suggest how I can do this?

I can suggest you to call "base.Show()" before you will display dialog
form from "Load" event.

HTH
Marcin
 
Back
Top