SelectionRange Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Represents a date selection range in a month calendar control.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)


public sealed class SelectionRange


Initializes a new instance of the SelectionRange class.

System_CAPS_pubmethodSelectionRange(DateTime, DateTime)

Initializes a new instance of the SelectionRange class with the specified beginning and ending dates.


Initializes a new instance of the SelectionRange class with the specified selection range.


Gets or sets the ending date and time of the selection range.


Gets or sets the starting date and time of the selection range.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


This API supports the product infrastructure and is not intended to be used directly from your code. Returns a string that represents the SelectionRange.(Overrides Object.ToString().)

The SelectionRange is the date or dates selected and highlighted on the MonthCalendar control. If only one date is selected, the Start and End property values will be equal. The SelectionRange can be changed by the user clicking a date while dragging the mouse pointer across the desired dates, or you can set the range in code. For example, you might want to have the user enter a date range into two TextBox controls or two DateTimePicker controls and set the SelectionRange based on those dates.

The following example sets the SelectionRange property of a MonthCalendar control based on two dates entered into two TextBox controls when a Button is clicked. This code assumes new instances of a MonthCalendar control, two TextBox controls, and a Button have been created on a Form. You might consider adding code to validate the Text assigned to the text boxes to verify that they contain valid dates.

private void button1_Click(object sender,
                           EventArgs e)
   // Set the SelectionRange with start and end dates from text boxes.
      monthCalendar1.SelectionRange = new SelectionRange(
   catch(Exception ex)

.NET Framework
Available since 1.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top