Monday, December 04, 2006

Note To Self: Stop Being Lazy and Write & Use ExtenderProviders

DevXBreathe New Life into Old Controls with ExtenderProviders

"From the beginning, the Tag property has been a Visual Basic programming staple. Any time you want to attach a little extra bit of information, you can put it in the Tag property. In .NET, the Tag property became even more useful, allowing you to store objects rather than just strings.

While Tag is great, there are times when it's just not quite enough. What if you're working on a large project and some other developer needs to use the same Tag property for something else? You could store a collection in the Tag property where you can both put values but that requires extra coordination. Or you could subclass the control to add an extra property to it, but that would give you a whole new class to debug and maintain. Wouldn't it be nice if you could just add an extra Tag property to a control for your own private use?

With ExtenderProviders you can! An ExtenderProvider is a component that adds any sort of extra service to existing controls and components. The ErrorProvider, HelpProvider, and ToolTip components are all provider classes that come with Visual Studio. ..."

All to often I'm inheriting and extending to add new stuff to existing controls. I've been wanting to stop that and, where possible, use Extenders.

For example, I've been using a WinXP compatible Vista like Prompt/Cue Textbox (TextBox with Cue/Prompt) in some of my apps. And I really like how it adds an additional way for me to help and inform my users.

But now I want to add it to my combobox's too (and other text entry controls). I'm thinking that a prompt/cue like feature could be a cool extender... But I've been too lazy to implement it.

Well the above article reminded me to tell myself (I talk to myself a lot, can you tell?  ;) to stop being lazy and get coding. At least prove it's possible or not...

Sounds like a possible "when the game server is down" thing to do. :)

Related Past Post XRef:
TextBox with Cue/Prompt

No comments: