Inheritance and events

G

Guest

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.
 
J

Jon Skeet [C# MVP]

Rik Brooks said:
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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top