通过


MonthCalendar.SelectionRange 属性

定义

获取或设置月份日历控件的选定日期范围。

public:
 property System::Windows::Forms::SelectionRange ^ SelectionRange { System::Windows::Forms::SelectionRange ^ get(); void set(System::Windows::Forms::SelectionRange ^ value); };
public System.Windows.Forms.SelectionRange SelectionRange { get; set; }
[System.ComponentModel.Bindable(true)]
public System.Windows.Forms.SelectionRange SelectionRange { get; set; }
member this.SelectionRange : System.Windows.Forms.SelectionRange with get, set
[<System.ComponentModel.Bindable(true)>]
member this.SelectionRange : System.Windows.Forms.SelectionRange with get, set
Public Property SelectionRange As SelectionRange

属性值

包含所选范围的开始日期和结束日期的 A SelectionRange

属性

例外

Start分配SelectionRange的值小于月份日历控件允许的最小日期。

-或-

Start分配SelectionRange的值大于月日历控件允许的最大日期。

-或-

End分配SelectionRange的值小于月份日历控件允许的最小日期。

-或-

End分配SelectionRange的值大于月日历控件允许的最大日期。

注解

设置此属性在功能上等效于使用 SetSelectionRange 该方法。 可以通过设置或SelectionEnd属性来单独设置SelectionStart开始日期和结束日期。 无法通过设置SelectionRange.Start属性的SelectionRangeSelectionRange.End属性值来更改开始日期和结束日期。 应使用 SelectionStartSelectionEndSetSelectionRange

Start如果属性值SelectionRange大于其End属性值,则交换日期;End属性值将成为开始日期,Start属性值将成为结束日期。

注释

选择某个区域时,使用导航按钮滚动日历显示可能会导致意外结果(例如,不保留日期范围)。 如果单个月份的显示范围为 2001/04/01 到 2001/04/10,将日历滚动到 3 月会将所选范围更改为:2001/03/01/2001 至 2001/03/10。 如果显示多个月,例如 2001/04/01/2001 的 3 月和 4 月,将日历滚动回 1 月和 2 月,将所选范围更改为:2001/01/01/2001 至 2001/01/10。

注释

SelectionRange MonthCalendar为启用了视觉样式的控件设置将导致选择范围无法正确绘制控件。

适用于

另请参阅