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.

次のコード例は、プロパティとSelectionStart SelectionEndプロパティの使用方法を示しています。The following code example demonstrates how to use the SelectionStart and SelectionEnd properties. この例を実行するにはMonthCalendar 、という名前MonthCalendar1のコントロールを含むフォームに次のコードを貼り付け、フォームのコンストラクター 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

注釈

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 SelectionStartた日数を超える日付を設定すると、の値が調整されます。 MaxSelectionCountは、選択した日数がMaxSelectionCountと等しいように自動的に設定されます。 SelectionStartIf 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.

注意

MaxSelectionCountSelectionStartSelectionEndの差ではなく、選択範囲の日数を表します。MaxSelectionCount represents the number of days in the selection, not the difference between SelectionStart and SelectionEnd. たとえば、が 7 MaxSelectionCount (既定値) SelectionStartの場合、とSelectionEndは6日以内である必要があります。For example, if MaxSelectionCount is 7 (the default), then SelectionStart and SelectionEnd can be no more than six days apart.

注意

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

適用対象

こちらもご覧ください