PC Review


Reply
Thread Tools Rate Thread

Detecting user changes to a control

 
 
James Daughtry
Guest
Posts: n/a
 
      13th Nov 2006
Let's say that I have some data bound controls on a form. What I want
to do is check for a dirty state on those controls for when the user
actively changes a value and throw a message box prompting for
confirmation. However, if I use the TextChanged event on a text box,
for example, the message box will be thrown *any* time the text is
changed, including databinding and navigating records even if the
"state" isn't dirty according to my application.

Now, for a text box I can grab the KeyPress event and assume that a
change is made, but this isn't so simple for other controls like check
boxes or numeric up downs.

Is there a clean way of doing what I want without handling every event
under creation and manually doing the kind of stuff that I would expect
..NET to do for me? ;-)

Thanks!

 
Reply With Quote
 
 
 
 
Bob Powell [MVP]
Guest
Posts: n/a
 
      16th Nov 2006
Perhaps using the validating event would be better for your case.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.



"James Daughtry" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Let's say that I have some data bound controls on a form. What I want
> to do is check for a dirty state on those controls for when the user
> actively changes a value and throw a message box prompting for
> confirmation. However, if I use the TextChanged event on a text box,
> for example, the message box will be thrown *any* time the text is
> changed, including databinding and navigating records even if the
> "state" isn't dirty according to my application.
>
> Now, for a text box I can grab the KeyPress event and assume that a
> change is made, but this isn't so simple for other controls like check
> boxes or numeric up downs.
>
> Is there a clean way of doing what I want without handling every event
> under creation and manually doing the kind of stuff that I would expect
> .NET to do for me? ;-)
>
> Thanks!
>



 
Reply With Quote
 
James Daughtry
Guest
Posts: n/a
 
      17th Nov 2006
Bob Powell [MVP] wrote:
> Perhaps using the validating event would be better for your case.


I'll look into that. I must have been mistaken about when and how the
validating event is raised. What I ended up doing was providing an
interface in my user controls to enable and disable events. That way
the parent form can disable events when a non-user change is done and
re-enable them afterward.

 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Detecting a value change in a control rhardy Microsoft Access VBA Modules 9 12th Mar 2009 04:52 PM
Detecting a tray control Larry Smith Microsoft Dot NET Framework Forms 2 21st Apr 2007 04:21 PM
Detecting a control in a cell? cmpcwil2 Microsoft Excel Programming 1 25th Apr 2006 04:19 PM
Detecting User =?Utf-8?B?S3Jpemhlaw==?= Microsoft Access Security 2 19th Jul 2005 03:18 PM
Detecting Control Changes Michael Albanese Microsoft Dot NET 1 10th Dec 2003 08:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:48 AM.