MonthCalendar.SelectionStart プロパティ

定義

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

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

プロパティ値

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

属性

例外

日付値が MinDate より小さい値です。The date value is less than MinDate.

- または --or- 日付値が MaxDate より大きい値です。The date value is greater than MaxDate.

次のコード例は、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 プロパティの値を SelectionEnd プロパティの現在の値よりも後の日付に設定した場合、SelectionEnd は自動的に SelectionStart に等しく設定されます。If you set the value of the SelectionStart property to a date that is later than the current value of the SelectionEnd property, SelectionEnd is automatically set equal to SelectionStart.

@No__t-1 プロパティによって指定された日数を超過するように SelectionStart の日付を設定すると、SelectionEnd の値が調整されます。SelectionEnd が自動的に設定され、選択した日数が MaxSelectionCount と等しくなります。If you set a date in SelectionStart that causes the selection to exceed the number of days specified by the MaxSelectionCount property, the value of SelectionEnd is adjusted; SelectionEnd 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.

適用対象

こちらもご覧ください