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

屬性值

SelectionRange

SelectionRange,具有選取範圍的開始和結束日期。

屬性

例外狀況

受指派之 SelectionRangeStart 值小於月曆控制項允許的最小日期。

-或- 受指派之 SelectionRangeStart 值大於月曆控制項允許的最大日期。

-或- 受指派之 SelectionRangeEnd 值小於月曆控制項允許的最小日期。

-或- 受指派之 SelectionRangeEnd 值大於月曆控制項允許的最大日期。

備註

設定此屬性的功能相當於使用 SetSelectionRange 方法。 您可以藉由設定 SelectionStartSelectionEnd 屬性,個別設定開始和結束日期。 您無法藉由設定 SelectionRange.Start 屬性的 SelectionRangeSelectionRange.End 屬性值來變更開始和結束日期。 您應該使用 SelectionStartSelectionEndSetSelectionRange

Start如果 的 SelectionRange 屬性值大於其 End 屬性值,則會交換日期; End 屬性值會變成開始日期, Start 而屬性值會變成結束日期。

注意

選取範圍時,捲動行事曆顯示與導覽按鈕可能會導致非預期的結果 (例如,日期範圍不會保留) 。 如果您的單一月份顯示範圍為 04/01/2001 到 04/10/2001,將行事曆捲動至 3 月會將選取的範圍變更為:2001/03/01/2001 到 03/10/2001。 如果您顯示多個月份,例如 3 月和 4 月,選取範圍為 2001/04/01/2001 到 04/10/2001,則會將行事曆捲動回 1 月和 2 月,將選取的範圍變更如下:2001/01/01/2001。

注意

SelectionRange針對已啟用視覺化樣式的 MonthCalendar 控制項設定 ,會導致選取範圍無法正確繪製控制項。

適用於

另請參閱