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