Would you modify a textbox to be more intelligent w.r.t bound data?

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,081
Programming Experience
10+
I currently do a huge amount of work (IMHO) with making bound textboxes have some sensible functionality, and I'm wondering if I can make this more intelligent through inheriting them.

I currently have a scheme whereby I have code that can crawl the entire form and pick up all the text boxes. I can hence quickly and easiely disable or enable them by iterating the collection i keep them in

I thought about improving this using a trick I have for the binding enumeration instead; I currently take each data source and iterate the controls bound to it, setting the maxlength property to be the length of the datasource, if it so happens that they are textboxes - i could extend this to build a collection set and know which controls are bound to which data. if any of those data sources have no data, i can disable the assocaiated controls

I started to question if this ios the most sensible way.. i.e have a ListChanged event on the form, that listens for changes to the data source list. if there is no data to show, then enumaerate all the bound cntrols and disable them..

But then I thought "wouldnt this behaviour be better off in a control itself?"
Can I write an addition to the code for a textbox so that, upon being bound to data, it changes its maxlength to matcht he data, and if there is ever no data to show (in the datasource list) then it disables itself?

Would you guys choose to make textbox this intelligent?
 
Back
Top