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 usar el SelectionStart, TodayDate y SelectionEnd propiedades.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 formulario que contenga un MonthCalendar control denominado MonthCalendar1y llamar a la ShowAWeeksVacationOneMonthFromToday método desde el constructor del formulario o Load 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, el TodayDate propiedad devuelve la fecha actual del sistema y la TodayDateSet propiedad es false.By default, the TodayDate property returns the current system date, and the TodayDateSet property is false. Establecer el TodayDate conjuntos de propiedades el TodayDateSet propiedad true y, a partir de ese punto, el valor devuelto por la TodayDate propiedad es el que establezca 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: