Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Compact Framework / August 2007

Tip: Looking for answers? Try searching our database.

Event: raised by user action or application code?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daan - 31 Aug 2007 15:00 GMT
I have a dateTimePicker with a ValueChanged event handler attached.
But I only want to execute the event handling code if the USER has
changed the value of the picker and not if my own application code
ajusts the value of the dateTimePicker. How can I discriminate where
the event came from? Perhaps I can use the sender or EventArgs for
that, but I cannot find how. Any suggestions?
Daan - 31 Aug 2007 15:07 GMT
> I have a dateTimePicker with a ValueChanged event handler attached.
> But I only want to execute the event handling code if the USER has
> changed the value of the picker and not if my own application code
> ajusts the value of the dateTimePicker. How can I discriminate where
> the event came from? Perhaps I can use the sender or EventArgs for
> that, but I cannot find how. Any suggestions?

I have figured out a workaround that makes sure the event is not
handled when the value is updated by my own code: first remove the
attached event handler, than update the value of the dateTimePicker,
then re-attach the event handler. It works, but I still wonder if
there is a better solution.
<ctacke/> - 31 Aug 2007 15:09 GMT
Before you modify the value in code either detach the event handler and
reattach when you're done or set a boolean flag that the handler looks at
before acting.

Signature

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com

>I have a dateTimePicker with a ValueChanged event handler attached.
> But I only want to execute the event handling code if the USER has
> changed the value of the picker and not if my own application code
> ajusts the value of the dateTimePicker. How can I discriminate where
> the event came from? Perhaps I can use the sender or EventArgs for
> that, but I cannot find how. Any suggestions?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.