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

Definición

Obtiene o establece el valor que MonthCalendar usa como fecha actual.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

Valor de propiedad

DateTime que representa la fecha actual.A DateTime representing today's date. El valor predeterminado es la fecha actual del sistema.The default value is the current system date.

Excepciones

El valor es menor que la fecha mínima permitida.The value is less than the minimum allowable date.

O bien-or- El valor es superior a la fecha mínima permitida.The value is greater than the maximum allowable date.

Ejemplos

En el ejemplo de código siguiente se muestra cómo SelectionStartusar TodayDate las SelectionEnd propiedades, y.The following code example demonstrates how to use the SelectionStart, TodayDate and SelectionEnd properties. Para ejecutar el ejemplo, pegue el código siguiente en un MonthCalendar formulario que contenga un MonthCalendar1control denominado y llame ShowAWeeksVacationOneMonthFromToday al método desde el constructor del formulario Load o el método de control de eventos.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

Comentarios

De forma predeterminada, TodayDate la propiedad devuelve la fecha actual del sistema y TodayDateSet la propiedad falsees.By default, the TodayDate property returns the current system date, and the TodayDateSet property is false. Al establecer TodayDate la propiedad, TodayDateSet se establece true la propiedad en y, a partir de ese punto, TodayDate el valor devuelto por la propiedad es el que establece el usuario.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.

Se aplica a

Consulte también: