Inheritance doubt.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ravimama

    #1

    Inheritance doubt.

    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

  • Larry Lard

    #2
    Re: Inheritance doubt.


    Ravimama wrote:[color=blue]
    > 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.[/color]

    I suspect you might be doing this:

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

    derived form:
    Overrides Sub Button2_Click(s ender, 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(s ender, e) Handles Button2.Click
    OnButton2Click
    End Sub

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

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

    --
    Larry Lard
    Replies to group please

    Comment

    • Ravimama

      #3
      Re: Inheritance doubt.

      Thanks mate! It worked. This is what I was looking for.

      Comment

      Working...