Detect change in TextBox + currencymanager without calling EndCurrentEdit()

A

Andy Gilman

I want to enable a 'Save' button when a bound textbox changes.
I am using a dataview and binding my textcontrol to a field on that
dataview.
I cant find ANY event that will tell me when the textbox changes.

Any message I can find online regarding similar issues tells me to call
'EndCurrentEdit' on the currency manager or data row before i save it. Well
thats
not the problem here. I want to be able to tell when the user starts typing.
I can do this on grids just fine, but i cannot find any way to do it on a
textbox.

Do I really have to capture each TextChanged event myself and set the status
of the button accordingly?

-simon
 
A

Andy Gilman

how strange. i never thought to check the ColumnChanging event but that
seems to get fired when i make a change and move off a text cell. i would
have figured that if a column changes then a row also changes(!) but MS
obvsiously disagree.

i think its strange though because the TextChanging event will be fired when
you just type a letter in a textbox, but in this case ColumnChanging doesnt
get fired until you move off the cell. isnt this how databinding works
though? that is - doesnt the TextChanging event triggers the binding?

looks like i'll have to add 'TextChanging' events to all my text controls in
order to be able to enable my Save button to become highlighted depending
upon changes in the data.

does this sound correct? or is there another approach?

-andy
 
G

Guest

Personally, I think it's a lot of work to trap the TextChanged event. Plus I've been programming long enough to remember the days of painfully slow computers and trapping TextChanged was a big NO-NO because it really slowed down performance. So I tend to only use it if there's a compelling reason. To me, it's a whole lot easier to allow the users to click their little hearts out on the Save button and get a "Nothing to save" message than it is to try to time enabling and disabling of events to user activities. I wouldn't think that data binding would be triggered by TextChanged because it would be time consuming to do on every keystroke.

That said, here's are some more thoughts: Do you really want to enable to Save button on the first key-stroke? Would you not want to validate the data entry first? Then you could use either Validating (occurs before the change is official) or Validated (after validation is done). If you decide to use TextChanged, then make sure there is only ONE routine that gets called by all the affected controls. Then you've only got one place to make changes. You could still have individual event handlers for specific textboxes if there's something special to do and then call your default routine. The controls that don't need to do anything else can just be assigned the default routine as the event handler. Another place you could handle it is Leave

Hope that helps.
 

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