MonthCalendar.TodayDate MonthCalendar.TodayDate MonthCalendar.TodayDate MonthCalendar.TodayDate Property

定義

今日の日付として MonthCalendar で使用される値を取得または設定します。Gets or sets the value that is used by MonthCalendar as today's date.

public:
 property DateTime TodayDate { DateTime get(); void set(DateTime value); };
public DateTime TodayDate { get; set; }
member this.TodayDate : DateTime with get, set
Public Property TodayDate As DateTime

プロパティ値

今日の日付を表す DateTimeA DateTime representing today's date. 既定値は、現在のシステム日付です。The default value is the current system date.

例外

値は、許容される最小値未満の日付です。The value is less than the minimum allowable date.

- または --or- 値は、許容される最大値を超える日付です。The value is greater than the maximum allowable date.

次のコード例は、使用する方法を示します、 SelectionStartTodayDateSelectionEndプロパティ。The following code example demonstrates how to use the SelectionStart, TodayDate 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

注釈

既定で、TodayDateプロパティは、現在のシステム日付を返します、TodayDateSetプロパティはfalseします。By default, the TodayDate property returns the current system date, and the TodayDateSet property is false. 設定、TodayDateプロパティ セット、TodayDateSetプロパティをtrueと、その時点では、によって返される値、TodayDateプロパティは、ユーザー 1 を設定します。Setting the TodayDate property sets the TodayDateSet property to true and, from that point, the value returned by the TodayDate property is the one the user sets.

適用対象

こちらもご覧ください