Re: How to call base buttons onclick event



Adam <adam2001usa@xxxxxxxxxxx> wrote:
> This is fine, but it still causes my events to be called twice. In the
> derived form's constructor I tried adding
>
> base.button1.Click -= new System.EventHandler(base.button1_Click);
>
> However, the click event in my derived form still seems to be called
> twice (the message box shows twice).

Thinking about it - try changing the above to:

button1.Click -= new System.EventHandler(button1_Click);

When the event handler is first added, it'll be added with a
polymorphic reference to the derived handler. That's the reference you
need to remove, I suspect!

It would be easier just not to add the second handler though - *just*
override the first one.

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
.