views:

110

answers:

1

i have a windows form that inherites from another windows form in the same project, the problem is when i click a button in the inherited form the eventhandler fires twice performing the event in the parent form and then performs the event in the inherited form . any suggestions?

http://www.metacafe.com/watch/852308/inheritied%5Fforms%5Fc/ in this video u will see what am doing exactly and the problem am facing is in the end of this video .. u will see exactly what i mean –

+1  A: 

This is the way it's supposed to work. You have two event handlers, both are executed. I would suggest the following:

In the parent form, add a method

Protected Overridable Sub OnOKButtonClick()
    MsgBox("Parent Form OK Button Clicked")
End Sub

which you call from the button's click event. In the inherited form, remove the button click event handler, and override the OnButtonClick method

Protected Overrides Sub OnOKButtonClick()
    MsgBox("Inherited Form OK Button Clicked")
End Sub

This should accomplish what you are after.

Tom Juergens