How to select a Range of Dates in the MonthCalendar Control

MonthCalendar control provides us selection of the date range, however we can select a date in DateTimePicker but DateTimepicker enables the user to select a single DateTime value. But you can set a range of dates or get a selection range set by the user by using properties of the MonthCalendar control.
We can understand this with the help of following code sample that demonstrates how to set a selection range.


  1. Private Sub SelectDateRange()
  2.     Dim StartDate As Date = New DateTime(2011, 9, 21)
  3.     Dim EndDate As Date = New DateTime(2011, 9, 25)
  4.     MonthCalendar1.SelectionRange = New SelectionRange(StartDate, EndDate)
  5. End Sub


  1. private void SelectDateRange()
  2. {
  3.  System.DateTime StartDate = new DateTime(2011, 9, 21);
  4.  System.DateTime EndDate = new DateTime(2011, 9, 25);
  5.  MonthCalendar1.SelectionRange = new SelectionRange(StartDate, EndDate);
  6. }

above code will select the daterange between 21/9/2011 to 25/9/2011.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>