PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms About textbox Validating, Validated & TextChanged

Reply

About textbox Validating, Validated & TextChanged

 
Thread Tools Rate Thread
Old 10-02-2006, 08:25 AM   #1
Steven Spits
Guest
 
Posts: n/a
Default About textbox Validating, Validated & TextChanged


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

- - -


  Reply With Quote
Old 10-02-2006, 11:23 AM   #2
Dmytro Lapshyn [MVP]
Guest
 
Posts: n/a
Default Re: About textbox Validating, Validated & TextChanged

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
>
> - - -
>
>



  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off