Re: Active Form or Form Focus

  • Thread starter Brian P. Hammer
  • 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
 
I

Ian Cooper

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
 
I

Ian Cooper

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
 
B

Brian P. Hammer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top