How do i stop event handler firing twice?

G

Guest

I have a base winform Base and a form that inherits from it Child
in the base form there is an event handler for a combo box click

Protected Overrideable Sub cboPickList_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles cboPickList.SelectedIndexChanged
DoStuff
End Sub

and in Child Form

Protected Overrides Sub cboPickList_SelectedIndexChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles cboPickList.SelectedIndexChanged
DoOtherStuff
End Sub

I would have expected that on a cboPickList SelectedIndexChanged event the
Child form event handler would be called and that the Base form one would not
however the Child Form handler is called TWICE. It looks like it is catching
an event from both the Child and Base forms

Removing the Handles clause from the base form seems to stop this however
sometimes i want the base form handler to be called (when a different child
does not override it)

any ideas how to stop this?

guy
 
H

Herfried K. Wagner [MVP]

guy said:
[Inherited handlers]

You may want to remove the handler added in the base class in the derived
class:

\\\
RemoveHandler Me.Button1.Click, AddressOf MyBase.Button1_Click
///
 
G

Guest

Thanks Herfried I should have thought of that!

cheers

guy

Herfried K. Wagner said:
guy said:
[Inherited handlers]

You may want to remove the handler added in the base class in the derived
class:

\\\
RemoveHandler Me.Button1.Click, AddressOf MyBase.Button1_Click
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top