PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
About textbox Validating, Validated & TextChanged
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Framework Forms
About textbox Validating, Validated & TextChanged
![]() |
About textbox Validating, Validated & TextChanged |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hi,
I have a textbox that should be numeric, so I've written some code in the Validating event. When the text was changed (and if it's valid!), I need to compute some other values. I've done this in the Validated event. However, when the users tabs over that field, the Validating & Validated event is triggered even if nothing changed. I've solved this by setting textbox.Tag to false in the Enter event. In the TextChanged event the tag is set to true and in the Validated event I only run the code if the tag is true. Isn't there a better way? Some .IsDirty property? Steven - - - |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Hi Steven,
I think your approach is quite fine. There is no out-of-the-box approach to check whether a textbox is "dirty". However, with your approach, the user might have edited the value and then reverted it back, but you mark the text box as dirty upon the first change. Might be better to remember the original value on Enter and then compare it with the current one upon Validating. "Steven Spits" <nospam@company.com> wrote in message news:%23vcHushLGHA.2828@TK2MSFTNGP12.phx.gbl... > Hi, > > I have a textbox that should be numeric, so I've written some code in the > Validating event. When the text was changed (and if it's valid!), I need > to compute some other values. I've done this in the Validated event. > > However, when the users tabs over that field, the Validating & Validated > event is triggered even if nothing changed. > > I've solved this by setting textbox.Tag to false in the Enter event. In > the TextChanged event the tag is set to true and in the Validated event I > only run the code if the tag is true. > > Isn't there a better way? Some .IsDirty property? > > Steven > > - - - > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

