|
-
Jun 12th, 2008, 11:28 AM
#1
Thread Starter
Junior Member
MonthCalendar -> automatic execution of dateChanged event
Hi!
I'm working with a windows application in .Net2.0 and I have a monthCalendar in one of my forms.
My problem is that this control always executes automaticaly its dateChanged event every 2 minutes.
I don't know if that's normal but is very anoying. I would like to know if there's any way to configurate this time or something similar to prevent the event to be executed unless I change the selected date.
Thankyou very much!1 Best regards!!
-
Jun 12th, 2008, 11:34 AM
#2
Addicted Member
Re: MonthCalendar -> automatic execution of dateChanged event
I think this is by design.
The MonthCalendar control simply forwards the MCN_SELCHANGE notification it
gets from OS.
The MCN_SELCHANGE notification is being sent by the Month Calendar control
every two minutes to ensure that the calendar is automatically updated in
the event that
the date should change while the control is being displayed.
However, we has a simple workaround for the application: in the
DateChangedEvent, see if e.Start and e.End point to the same day. It they
do, then the date did not really change.
-
Jun 12th, 2008, 11:39 AM
#3
Re: MonthCalendar -> automatic execution of dateChanged event
actually monthcalender automatically get MCN_SELCHANGE notification from operating system to keep it updated and hence it fires this event automatically but you can put this check
Code:
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
If e.Start <> e.End Then
End If
End Sub
Ref
__________________
Rate the posts that helped you 
-
Jun 12th, 2008, 11:41 AM
#4
Thread Starter
Junior Member
Re: MonthCalendar -> automatic execution of dateChanged event
I see.. I did not think that simple solution.
I'll try this but surelly it will work.
Thanks a lot for your quick response!!!
-
Jun 12th, 2008, 02:00 PM
#5
Re: MonthCalendar -> automatic execution of dateChanged event
If you are actually watching the event you might want to do something like this:
Code:
Dim lstDT As Date = Now
Private Sub MonthCalendar1_DateChanged(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
If e.Start = lstDT Then
'date didn't change
Else
lstDT = e.Start 'date did change
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|