MonthCalendar.SelectionStart MonthCalendar.SelectionStart MonthCalendar.SelectionStart MonthCalendar.SelectionStart Property

定義

選択されている日付範囲の開始日を取得または設定します。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. この例を実行するには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

注釈

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

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

注意

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.

適用対象

こちらもご覧ください