MonthCalendar.SelectionEnd MonthCalendar.SelectionEnd MonthCalendar.SelectionEnd MonthCalendar.SelectionEnd Property

定義

選択されている日付範囲の終了日を取得または設定します。Gets or sets the end date of the selected range of dates.

public:
 property DateTime SelectionEnd { DateTime get(); void set(DateTime value); };
[System.ComponentModel.Browsable(false)]
public DateTime SelectionEnd { get; set; }
member this.SelectionEnd : DateTime with get, set
Public Property SelectionEnd As DateTime

プロパティ値

選択範囲の最後の日を示す DateTimeA DateTime indicating the last date in the selection range.

例外

日付値が MinDate 値未満です。The date value is less than the MinDate value.

- または --or- 日付値が MaxDate 値を超えています。The date value is greater than the MaxDate value.

次のコード例は、使用する方法を示します、SelectionStartSelectionEndプロパティ。The following code example demonstrates how to use the SelectionStart and SelectionEnd properties. 例を実行するには、含むフォームに次のコードを貼り付けます、MonthCalendarという名前のコントロールMonthCalendar1を呼び出すと、ShowAWeeksVacationOneMonthFromTodayフォームのコンス トラクターのメソッドまたはLoadイベント処理メソッド。To run the example, paste the following code into a form containing a MonthCalendar control named MonthCalendar1, and call the ShowAWeeksVacationOneMonthFromToday method from the form's constructor or Load event-handling method.

// Computes a week one month from today.
void ShowAWeeksVacationOneMonthFromToday()
{
   System::DateTime today = this->MonthCalendar1->TodayDate;
   int vacationMonth = today.Month + 1;
   int vacationYear = today.Year;

   if ( today.Month == 12 )
   {
      vacationMonth = 1;
      ++vacationYear;
   }
   
   // Select the week using SelectionStart and SelectionEnd.
   this->MonthCalendar1->SelectionStart =
      System::DateTime( today.Year, vacationMonth, today.Day - 1 );
   this->MonthCalendar1->SelectionEnd =
      System::DateTime( today.Year, vacationMonth, today.Day + 6 );
}
// Computes a week one month from today.
private void ShowAWeeksVacationOneMonthFromToday()
{
	System.DateTime today = this.MonthCalendar1.TodayDate;
	int vacationMonth = today.Month + 1;
	int vacationYear = today.Year;

	if (today.Month == 12)
	{
		vacationMonth = 1;
		++vacationYear;
	}

	// Select the week using SelectionStart and SelectionEnd.
	this.MonthCalendar1.SelectionStart = 
		new System.DateTime(today.Year, vacationMonth, today.Day-1);
	this.MonthCalendar1.SelectionEnd = 
		new System.DateTime(today.Year, vacationMonth, today.Day+6);
}

' Computes a week one month from today.
Private Sub ShowAWeeksVacationOneMonthFromToday()
     
    Dim today As Date = monthCalendar1.TodayDate
    Dim vacationMonth As Integer = today.Month + 1
    Dim vacationYear As Integer = today.Year
    If (today.Month = 12) Then
        vacationYear += 1
        vacationMonth = 1
    End If

    Me.monthCalendar1.SelectionStart = _
        New Date(vacationYear, vacationMonth, today.Day - 1)
    Me.monthCalendar1.SelectionEnd = _
        New Date(vacationYear, vacationMonth, today.Day + 6)
End Sub

注釈

値を設定した場合、SelectionEndプロパティの現在の値よりも前の日付をSelectionStartプロパティ、SelectionStartは自動的に設定すると等しいSelectionEndします。If you set the value of the SelectionEnd property to a date that is earlier than the current value of the SelectionStart property, SelectionStart is automatically set equal to SelectionEnd.

日付を設定した場合SelectionEnd選択範囲で指定された日数の数を超えるを原因となった、MaxSelectionCountプロパティの値は、SelectionStartが調整されます。SelectionStartが自動的にセットの日数が選択されているようにの指定と等しいMaxSelectionCountします。If you set a date in SelectionEnd that causes the selection to exceed the number of days specified by the MaxSelectionCount property, the value of SelectionStart is adjusted; SelectionStart is automatically set so that the number of days selected is equal to MaxSelectionCount.

注意

MaxSelectionCount 違いではない、選択範囲の日数を表すSelectionStartSelectionEndします。MaxSelectionCount represents the number of days in the selection, not the difference between SelectionStart and SelectionEnd. たとえば場合、MaxSelectionCountは 7 (既定)、SelectionStartSelectionEnd6 日以内を分解することができます。For example, if MaxSelectionCount is 7 (the default), then SelectionStart and SelectionEnd can be no more than six days apart.

注意

設定、SelectionRangeMonthCalendarvisual スタイルが有効になっているコントロールがコントロールに正しくないペイント選択範囲になります。Setting the SelectionRange for a MonthCalendar control that has visual styles enabled will result in the selection range not painting correctly on the control.

適用対象

こちらもご覧ください