Inheritance and events

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

    Inheritance and events

    Hi,

    My problem is in trying to extend events in the inheritance heirarchy. I
    have a custom control. It has 3 images on it. The custom control consumes the
    Click event. In the Click event of each of the images I fire the Click event
    of the control. Let's call the control custom_ancestor . I set the images to
    have protected access.

    Now I inherit from this custom_ancestor and change the bitmaps to something
    that I want for a specific application. Let's say that I call this image_new.

    Now I put image_new on a form. I call it custom1 on the form. I go to the
    clicked event and add some code. That code never gets fired off.

    I've read through a lot of web sites and tried the help files. I've changed
    modifiers back and forth. I've put messageboxes everywhere and taken them out.

    Can someone please help me out here? I'm stuck. I just want the click event
    of the object in the form to be fired when the clicked event of the topmost
    ancestor is fired.

    Thanks in advance.
    --
    Outside of a dog, a book is man's best friend. Inside a dog it's too dark to
    read
  • Jon Skeet [C# MVP]

    #2
    Re: Inheritance and events

    Rik Brooks <RikBrooks@disc ussions.microso ft.com> wrote:[color=blue]
    > My problem is in trying to extend events in the inheritance heirarchy. I
    > have a custom control. It has 3 images on it. The custom control consumes the
    > Click event. In the Click event of each of the images I fire the Click event
    > of the control. Let's call the control custom_ancestor . I set the images to
    > have protected access.
    >
    > Now I inherit from this custom_ancestor and change the bitmaps to something
    > that I want for a specific application. Let's say that I call this image_new.
    >
    > Now I put image_new on a form. I call it custom1 on the form. I go to the
    > clicked event and add some code. That code never gets fired off.
    >
    > I've read through a lot of web sites and tried the help files. I've changed
    > modifiers back and forth. I've put messageboxes everywhere and taken them out.
    >
    > Can someone please help me out here? I'm stuck. I just want the click event
    > of the object in the form to be fired when the clicked event of the topmost
    > ancestor is fired.[/color]

    I'm having trouble imagining the code you've got.
    Could you post a short but complete program which demonstrates the
    problem?

    See http://www.pobox.com/~skeet/csharp/complete.html for details of
    what I mean by that.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    Working...