How to get the selected date of a MonthCalendar control in C#

后端 未结 5 700
我寻月下人不归
我寻月下人不归 2020-12-28 13:46

How to get the selected date of a MonthCalendar control in C# (Window forms)

5条回答
  •  感情败类
    2020-12-28 14:10

    I just noticed that if you do:

    monthCalendar1.SelectionRange.Start.ToShortDateString() 
    

    you will get only the date (e.g. 1/25/2014) from a MonthCalendar control.

    It's opposite to:

    monthCalendar1.SelectionRange.Start.ToString()
    
    //The OUTPUT will be (e.g. 1/25/2014 12:00:00 AM)
    

    Because these MonthCalendar properties are of type DateTime. See the msdn and the methods available to convert to a String representation. Also this may help to convert from a String to a DateTime object where applicable.

提交回复
热议问题