MonthCalendar.SelectionEnd プロパティ

定義

選択されている日付範囲の終了日を取得または設定します。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.

次のコード例は、SelectionStart および SelectionEnd プロパティの使用方法を示しています。The following code example demonstrates how to use the SelectionStart and SelectionEnd properties. この例を実行するには、MonthCalendar1 という名前の @no__t 0 コントロールを含むフォームに次のコードを貼り付け、フォームのコンストラクターまたは Load のイベント処理メソッドから ShowAWeeksVacationOneMonthFromToday メソッドを呼び出します。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

注釈

@No__t-0 プロパティの値を、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.

@No__t-1 プロパティによって指定された日数を超過するように SelectionEnd の日付を設定すると、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 (既定値) の場合、SelectionStartSelectionEnd は6日以内に分けることができます。For example, if MaxSelectionCount is 7 (the default), then SelectionStart and SelectionEnd can be no more than six days apart.

注意

視覚スタイルが有効になっている @no__t 1 コントロールの SelectionRange を設定すると、コントロールで選択範囲の描画が正しく行われなくなります。Setting the SelectionRange for a MonthCalendar control that has visual styles enabled will result in the selection range not painting correctly on the control.

適用対象

こちらもご覧ください