How to Raise events from a form?

  • Thread starter Thread starter Graham Blandford
  • Start date Start date
G

Graham Blandford

Hi guys,

I'm sure this has been addressed before but can;t seem to find any specific
answers....

I have an MDI form that opens a child form.

What I would like to do is have a child form event - happens to be a toolbar
click - available to my mdi parent.

I'm sure it can be done - and in fact I think I've seen code in the past...
but now I need to employ it........

Any help would be appreciated.

Thanks,
Graham
 
* "Graham Blandford said:
I'm sure this has been addressed before but can;t seem to find any specific
answers....

I have an MDI form that opens a child form.

What I would like to do is have a child form event - happens to be a toolbar
click - available to my mdi parent.

I'm sure it can be done - and in fact I think I've seen code in the past...
but now I need to employ it........

Have a look at the 'AddHandler' and 'RemoveHandler' keywords...
 
Hi,

Declare the event then you can raise it.

In general declarations area

Public Event myevent(byval sender as object, byval e as eventargs)

To use

RaiseEvent myevent(me,new eventargs)

Ken
-------------------------
 
Thanks Ken,

But how do I then capture the event from the MDI form?

I have created the Public event in my MDI child, I perform thr raiseevent
in the toolbar event,
Public Event ToolbarClick(ByVal sender As Object, ByVal e As EventArgs)

Public Sub tbmain_ButtonClick(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tbmain.ButtonClick

RaiseEvent ToolbarClick(sender, e)

End Sub



but don't know what I am supposed to do in the parent?


I have tried something like this....

Private Sub ToolbarClicker(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ToolBarButtonClickEventArgs) Handles
frmChild.ToolbarClick

I'm sure I'm close... but no cigar....

Thanks,
Graham
 
Thanks Guys,

With your help I've managed to figure it out.

Thanks again,
Graham
 
Back
Top