I have a form in VB.NET that is used as a dialog in the main form. Its instances are always locally defined; there is no field for this. When the user clicks the OK button in the dialog box, he fires an event with one argument, an instance of one of my classes.
Since this is always a local variable, how can I add an event handler for this event? I searched for myself and found something, but I cannot figure it out ...
Code for the event, field in MyDialog:
public Event ObjectCreated(ByRef newMyObject as MyObject)
Code for the main form for calling the dialog: (not to mention the syntax)
Dim dialog As New MyDialog()
dialog.ShowDialog(Me)
AddHandler ObjectCreated, (what do I put here?)
As you can see, I am stuck on how to add a handler for my event. Can someone help me? Preferably with the best way to do this ...