Home All Groups Group Topic Archive Search About
Author
10 Mar 2006 9:18 AM
Ravimama
Hello All,

I am planning to use inheritance for forms which have similar controls
and properties. I tried to do it with a small example, but I am facing
some issues.

I created a base form (with 2 butttons) with overridable event
procedures. In the inheritance I created a 2 overriding event
procedures. The startup object was the base form. In the base form
button2 procedure I am calling the inherited form. The inherited form
loads but the inherited form button2 procedure fires twice. Why is
that? Please help me.

thank you in advance.

Ravi

Author
10 Mar 2006 10:24 AM
Larry Lard
Ravimama wrote:
> Hello All,
>
> I am planning to use inheritance for forms which have similar controls
> and properties. I tried to do it with a small example, but I am facing
> some issues.
>
> I created a base form (with 2 butttons) with overridable event
> procedures. In the inheritance I created a 2 overriding event
> procedures. The startup object was the base form. In the base form
> button2 procedure I am calling the inherited form. The inherited form
> loads but the inherited form button2 procedure fires twice. Why is
> that? Please help me.

I suspect you might be doing this:

base form:
Overrideable Sub Button2_Click(sender, e) Handles Button2.Click
    'base button2 click behaviour
End Sub

derived form:
Overrides Sub Button2_Click(sender, e) Handles Button2.Click
    'derived button2 click behaviour
End Sub

Because there are two Handles clauses, they will BOTH be called on
Button2.Click. What you should do is this:

base form:
Sub Button2_Click(sender, e) Handles Button2.Click
    OnButton2Click
End Sub

Protected Overrideable Sub OnButton2Click()
    'base button2 click behaviour
End Sub

derived form:
Overrides Sub OnButton2Click()
    'maybe:
    MyBase.OnButton2Click
    'derived button2 click behaviour
End Sub

--
Larry Lard
Replies to group please
Author
10 Mar 2006 10:57 AM
Ravimama
Thanks mate! It worked. This is what I was looking for.