Results 1 to 5 of 5

Thread: MonthCalendar -> automatic execution of dateChanged event

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Location
    Barcelona
    Posts
    29

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

  2. #2
    Addicted Member
    Join Date
    Feb 2008
    Location
    California
    Posts
    151

    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.

  3. #3
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    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

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2006
    Location
    Barcelona
    Posts
    29

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

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width