views:

34

answers:

0

I have a winform with a few textboxes databound to an object like so tbdecimalProp.DataBindings.Add("Text", activeUserInput, "decimalProp")

One of the properties I bound to is type Decimal. When the user enters text into textbox, and the control is validated, the users input is lost, and the value in the textbox reverts to what it was before.

I understand what is happening., but I want to preserve that user input. I think it may be confusing to automatically revert back to the original data. I want to give an error message, but keep the users data in the text box. I will validate again before "persisting" the values.

I don't like it when programs "automagically" change what I entered, so I don't want to do the same to my users. I want to tell them the input is wrong and give them a chance to fix it.

I have hooked the textbox.validating event and the databinding.parse event, but I don't see how "preserve" the users input. Did I describe my situation adequately?

If so, does anyone know a way to achieve the desired behavior?