Calling event from a separate class

  • Thread starter Thread starter Josh King
  • Start date Start date
J

Josh King

I have a windows form that opens up another windows form on top of it.
I'd like the newly opened window to call an event on the parent to
refresh it's data on the screen, as the new window closes. Does
somebody have an example of how to do this? The problem I'm having is
using that particular class instance, of the parent, that is already
open.
 
Josh,

The only place it is possible to fire an event is on the class that
defines an event. If you want to fire an event that is exposed on the
parent form, then you can create a method that when called, will fire the
event.

However, it sounds like this isn't what you want. Rather, it sounds
like your child form should expose an event of its own when it closes (or
use the Closed or Closing event). The parent event can then hook up to this
when it creates the child, and respond accordingly to that event when it is
fired.

Hope this helps.
 
Nicholas Paldino said:
Josh,

The only place it is possible to fire an event is on the class that
defines an event. If you want to fire an event that is exposed on the
parent form, then you can create a method that when called, will fire the
event.

However, it sounds like this isn't what you want. Rather, it sounds
like your child form should expose an event of its own when it closes (or
use the Closed or Closing event). The parent event can then hook up to this
when it creates the child, and respond accordingly to that event when it is
fired.

Hope this helps.


This concept makes sense although I need a base to go off of, in code.
Does this require making a delegate on the parent form and attaching
it to the child event?

Thanks,
 
Back
Top