none
MonthCalendar C# can't make multiple selection containing the last day of month RRS feed

  • Question

  • hello,

    im using a monthcalendar which i fix the maxdate to the last day of the current system month. unfortunately the user can not make a multiple selection containing the last day of the month. ex: if the user starts to select from 27th arrving to 31th it automatically cancel the selection and just select the 31th. can anyone help please?

    Tuesday, May 15, 2012 3:02 PM

Answers

  • I checked the reference code and they check very exact (maybe a little too good) when bounding the selection.

    Solution is: Set the end date to end of the day (23:59:59)

    monthCalendar1.MaxDate = new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.DaysInMonth(System.DateTime.Now.Year, System.DateTime.Now.Month),23,59,59);

    Thursday, May 17, 2012 2:23 PM

All replies

  • Hi Stephan,

    Welcome to the MSDN Forum.

    I don't think MonthCalendar supports Multiple selections. 

    If you want to select an arrange, please add one more this control in your application. One for the start date, and the other for the end date.

    If I have misunderstood any thing, please feel free to follow up.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Wednesday, May 16, 2012 10:36 AM
    Moderator
  • Hello,

    Thank's for your answer Mike but you are wrong. there's a property of MonthCalendar called MaxSelectionCount which limit the maximum of days user can select at a time, and other properties like SelectionStart and SelectionEnd(first day/last day selected) so yes MonthCalendar does support multiple selections.

    Merci.

    Wednesday, May 16, 2012 12:36 PM
  • Hi Stephan,

    Thank you for your clarification.

    I tried your scenario. I can use shift key to select multiple days, see this picture: 

    Did you try this way?

    My test way is just drag-drop the monthCalendar control in a form, and no more code or any actions.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 17, 2012 3:51 AM
    Moderator
  • Be aware that beside some think that, is the base class not windows forms. 

    The base class is System and in that Object and from that everything derives. 

    Windows forms (a very much derived and overriden class in most program languages) has an own forum.

    http://social.msdn.microsoft.com/Forums/en-US/suggest/threads

    In that forum are the experts for your question, 


    Success
    Cor

    Thursday, May 17, 2012 5:06 AM
  • Thank's guys.

    @ Mike, you are right it works with no other codes added but when i limit the Maxdate property to the last day of month (current month in my code) user can not select the last day of the month in a multiple selection.

    this.monthCalendar2.MaxDate = new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.DaysInMonth(System.DateTime.Now.Year, System.DateTime.Now.Month));

    My regards. 

    Thursday, May 17, 2012 1:47 PM
  • I checked the reference code and they check very exact (maybe a little too good) when bounding the selection.

    Solution is: Set the end date to end of the day (23:59:59)

    monthCalendar1.MaxDate = new System.DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, System.DateTime.DaysInMonth(System.DateTime.Now.Year, System.DateTime.Now.Month),23,59,59);

    Thursday, May 17, 2012 2:23 PM
  • Boothwine you are the Man!!! thank's
    Thursday, May 17, 2012 2:36 PM