none
MonthCalendar.SelectionEnd different return results in XP and Vista

    Question

  • I have a program in wich i use MonthCalendar control and it behaves realy
    strange.
    In Windows XP MonthCalendar.SelectionEnd returns the same result as
    MonthCalendar.SelectionStart, ie (12.12.2007 00:00)
    In Windows Vista MonthCalendar.Selection End returns
    MonthCalendar.SelectionStart - 1 second, ie (12.12.2007.23:59)

    I'm sing it for selecting Rows from Db and ofcourse in XP i get no result
    becouse TimeSpan between Start end End is 0.
    Is it normal behavior for XPs version of MonthCalendar.SelectionEnd to
    return same result as Selection.Satrt???
    Friday, August 17, 2007 3:09 PM

Answers

  • I have tried to see if I could find any documentation about this change but I find nothing.

     

    That you see this difference between XP and Vista is most likely because of changes to the underlying windows month calendar common control that the .NET MonthCalendar control uses. Since .NET rely on a control outside the framework it may behave different depending on what version of the common controls are available, as you have noticed.

     

    When I look in MSDN about MonthCalendar and the time part for SelectionStart and SelectionEnd it does not really mention anything about it and I would consider the time part of the DateTime structure returned as undefined. To avoid any confusion I suggest you always set the SelectionStart time part to 00:00 and SelectionEnd to 23:59. This will ensure your application will always behave as you expect.

    Friday, August 17, 2007 9:31 PM