Export (0) Print
Expand All

MonthCalendar.SetSelectionRange Method

Sets the selected dates in a month calendar control to the specified date range.

[Visual Basic]
Public Sub SetSelectionRange( _
   ByVal date1 As DateTime, _
   ByVal date2 As DateTime _
)
[C#]
public void SetSelectionRange(
 DateTime date1,
 DateTime date2
);
[C++]
public: void SetSelectionRange(
 DateTime date1,
 DateTime date2
);
[JScript]
public function SetSelectionRange(
   date1 : DateTime,
 date2 : DateTime
);

Parameters

date1
The beginning date of the selection range.
date2
The end date of the selection range.

Exceptions

Exception Type Condition
ArgumentException The date1 parameter value is less than the minimum date allowable for a month calendar control.

-or-

The date1 value is greater than the maximum allowable date for a month calendar control.

-or-

The date2 parameter value is less than the minimum date allowable for a month calendar control.

-or-

The date2 value is greater than the maximum allowable date for a month calendar control.

Remarks

Using this method is functionally equivalent to setting the SelectionRange property. You can set the start and end dates separately by setting either SelectionStart or SelectionEnd.

If you set the date1 parameter greater than the date2 parameter, the dates are exchanged; date2 becomes the start date, and date1 becomes the end date.

Note   Scrolling the calendar display with the navigation buttons when a range is selected can cause unexpected results. For example, the date range is not preserved. If you have a single month displayed with a range of 04/01/2001 to 04/10/2001, scrolling the calendar back changes the selected range as follows: 03/01/2001 to 03/10/2001. If you have multiple months displayed, such as March and April with a selected range of 04/01/2001 to 04/10/2001, scrolling the calendar back changes the selected range as follows: 01/01/2001 to 01/10/2001.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

MonthCalendar Class | MonthCalendar Members | System.Windows.Forms Namespace | SelectionStart | SelectionEnd | SelectionRange

Show:
© 2014 Microsoft