Overriding Controls

G

Guest

Good day,

I need to override many different types of controls: RichTextBox, Image,
TextBox, among others. I'm override just a few event handling methods for
them so they all have common event handling code. Basicaly I'm just adding
some event handling code that allows the control to be dragged and dropped
all over the form.

What class do I need to extend to do so? I tried extending
Windows.Forms.Controls but this doesn't work as RichTextBox, Image, etc are
all part of the Windows.Forms namespace.

I don't want to create a UserControl because then I'll have to create a
seperate class for each control.
 
M

Mohammad

Please correct me if I'm wrong, but it seems that you want to somehow
inherit from one of the common base classes for all Windows controls,
implement some sort of even handling there, and then make that class a
base class for windows controls. Correct?

If it is, then it can't be done. Not in .NET at least, not as far as I
know. Perhaps you could look into the Decorator pattern for a solution.
 
G

Guest

Mohammad,

I pretty much want to do the same thing. I want to write one set of code
and then hook this code into the Load event of all controls. I thought there
would be some way to hook into the Load event of the 'Control' class but, if
I understand you correctly, there is no way to do this in C#.net.

Or is there?

Robert W.
 

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