How to notifiy the creator of an object of an event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have multiple instances of frmDevice forms that were created by a single
frmMain. I'd like alert frmMain of certain frmDevice events.
What is the best way of doing this?
Should I create an event delegate? If so, then it seems that I would need to
pass a reference to frmMain to each frmDevice, so that I can attach a frmMain
handler.
I'm somewhat new at this, so would appreciate the help,
Thanks in advance,
Dennis
 
It sounds like you could use an events tutorial:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csref/html/vcwlkeventstutorial.asp

It seems that frmDevice should contain an event. The delegate for this event
will look something like this...

public delegate void MyDeviceEventHandler( frmDevice sender, DeviceEventArgs
e );

When frmMain creates a frmDevice, it attaches a handler to the frmDevice's
event. You only need to have the sender in the signature of the delegate if
you care where the event comes from.

Regards,

Tim Haughton
 
Back
Top