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