Re: Active Form or Form Focus

  • Thread starter Thread starter Brian P. Hammer
  • Start date Start date
B

Brian P. Hammer

Can you point me in a direction where I might see some examples of creating
form handlers.

Thanks,
Brian P. Hammer


Ian Cooper said:
How do I figure out when a MDI form receives the
focus. I need to update and refresh a form when it receives the focus
after some changes on another open form.

You need to set up a handler for the form's Activate event.
Ian Cooper
wwww.dnug.org.uk
 
Can you point me in a direction where I might see some examples of creating
form handlers.

Hi Brian,
The Windows Form Designer will help you do this. In C# you the events tab (lightning flash) of the Property Pages to add event handlers. Not sure about VB, I think that you use the bar on top of the editor.
The designer adds code to InitializeComponent() to subscribe to the event, so in this case the C# would be
this.Activated += new System.EventHandler(this.MDIChild_Activated);
assuming that the method on your class which encapsulates the delegate is:
private void MDIChild_Activated(object sender, System.EventArgs e)
{

}
There is a VB/C# friendly example on http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsMDI.aspx
(about halfway down the page entitled Child Window Activation)
HTH,
Ian Cooper
wwww.dnug.org.uk
 
Can you point me in a direction where I might see some examples of creating
form handlers.

Oops my bad you need to MdiChildActivate event in this case not the Activated event.

Ian Cooper
wwww.dnug.org.uk
 
Thanks Ian. I play around with it and see what I can come up with.

--
Brian P. Hammer
Ian Cooper said:
Can you point me in a direction where I might see some examples of creating
form handlers.

Hi Brian,
The Windows Form Designer will help you do this. In C# you the events tab
(lightning flash) of the Property Pages to add event handlers. Not sure
about VB, I think that you use the bar on top of the editor.
The designer adds code to InitializeComponent() to subscribe to the event,
so in this case the C# would be
this.Activated += new System.EventHandler(this.MDIChild_Activated);
assuming that the method on your class which encapsulates the delegate is:
private void MDIChild_Activated(object sender, System.EventArgs e)
{

}
There is a VB/C# friendly example on
http://samples.gotdotnet.com/quickstart/winforms/doc/WinFormsMDI.aspx
(about halfway down the page entitled Child Window Activation)
HTH,
Ian Cooper
wwww.dnug.org.uk
 
Back
Top