improving interface member functions of existing class (standard control)

  • Thread starter Thread starter Zytan
  • Start date Start date
Z

Zytan

I want to extend an existing class (a standard control), by making
more member functions, to improve the ease of its use. *I don't want
to make my own control, or add new functionality.* I just want to
improve the *interface* for existing functionality.

So, instead of doing this:
MyUnit.MyFunction(Control, ...)

I want:
Control.MyFunction(...)

So, I could inherit, but I doubt the above would work. I'd have to
actually make them the NEW control. Again, I don't want a NEW control
with NEW functionality. I just want to improve the interface to
controls that already exist. And it's ugly to have to make my own
unit and with my own function that has to accept the control as a
parameter each time...

Any ideas?

Zytan
 
I want to extend an existing class (a standard control), by making
more member functions, to improve the ease of its use. *I don't want
to make my own control, or add new functionality.* I just want to
improve the *interface* for existing functionality.

In 1.1 or 2.0, I don't see an easy way of doing that if you're ruling
out inheritence.

In future versions of .NET, what you're describing sounds like
"extension methods":

http://tinyurl.com/yoddc9
 
In 1.1 or 2.0, I don't see an easy way of doing that if you're ruling
out inheritence.

In future versions of .NET, what you're describing sounds like
"extension methods":

http://tinyurl.com/yoddc9

Wow, Patrick, this is precisely what I am asking about! So, it
doesn't exist, yet. Too bad. Very cool that they are working on it.

I realize that I didn't really explain very well what I wanted, but
you followed me, anyway. What I was actually looking to do was to add
methods to the RichTextBox class to allow EASY writing of formatted
text in a way that is intuitive to a user that knows nothing about its
internals. For instance, i want the next line printed in bolded red.
It's not so easy (AFAIK), so I made a class to handle it, and these
methods should be natively accessible via IntelliSense as this article
on Extension Methods describes. Very cool.

Zytan
 
Back
Top