codefinger
asked on
Validating a textbox...
I am a little confused about how to use CausesValidation in a WinForms application....here is what I want to accomplish:
The user is presented with a default value in a text box, but he/she can change it to anything except a blank or a value that has already been used. (I have a function that will check that.)
If the user attempts an invalid entry, a message box explaining the problem pops up, then after the user dismisses the message box, the value in the text box reverts to whatever it was before the user edited it.
How would I use CausesValidation and the Validation and/or Focus events to accomplish the above? I've been trying for hours now, but I think I may have coded myself into a corner....
Thanks in advance for your kind assistance.
The user is presented with a default value in a text box, but he/she can change it to anything except a blank or a value that has already been used. (I have a function that will check that.)
If the user attempts an invalid entry, a message box explaining the problem pops up, then after the user dismisses the message box, the value in the text box reverts to whatever it was before the user edited it.
How would I use CausesValidation and the Validation and/or Focus events to accomplish the above? I've been trying for hours now, but I think I may have coded myself into a corner....
Thanks in advance for your kind assistance.
Can you show us your code?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you need further assistance?
ASKER
Thanks. I did not even suspect that the text box has an UNDO function.