By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,678 Members | 1,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,678 IT Pros & Developers. It's quick & easy.

improving interface member functions of existing class (standard control)

P: n/a
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

Feb 9 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <11********************@j27g2000cwj.googlegroups.c om>,
zy**********@yahoo.com says...
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

--
Patrick Steele
http://weblogs.asp.net/psteele
Feb 12 '07 #2

P: n/a
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

Feb 12 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.