MonthCalendar.SelectionEnd MonthCalendar.SelectionEnd MonthCalendar.SelectionEnd MonthCalendar.SelectionEnd Property

Definición

Obtiene o establece la fecha final del intervalo de fechas seleccionado.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

Valor de propiedad

DateTime que indica la última fecha del intervalo de selección.A DateTime indicating the last date in the selection range.

Excepciones

El valor de fecha es menor que el valor MinDate.The date value is less than the MinDate value.

-o bien--or- El valor de fecha es mayor que el valor MaxDate.The date value is greater than the MaxDate value.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el SelectionStart y SelectionEnd propiedades.The following code example demonstrates how to use the SelectionStart 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

Si establece el valor de la SelectionEnd propiedad a una fecha que sea anterior al valor actual de la SelectionStart propiedad SelectionStart automáticamente se establece igual que 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.

Si establece una fecha SelectionEnd que hace que la selección supere el número de días especificado por el MaxSelectionCount propiedad, el valor de SelectionStart se ajusta; SelectionStart automáticamente conjunto para que el número de días seleccionado es igual a MaxSelectionCount.If 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.

Nota

MaxSelectionCount representa el número de días de la selección, no la diferencia entre SelectionStart y SelectionEnd.MaxSelectionCount represents the number of days in the selection, not the difference between SelectionStart and SelectionEnd. Por ejemplo, si MaxSelectionCount es 7 (el valor predeterminado), a continuación, SelectionStart y SelectionEnd pueden estar separados a no más de seis días.For example, if MaxSelectionCount is 7 (the default), then SelectionStart and SelectionEnd can be no more than six days apart.

Nota

Establecer el SelectionRange para un MonthCalendar dará como resultado el control que tiene habilitados estilos visuales en el intervalo de selección no se dibujará correctamente en el control.Setting the SelectionRange for a MonthCalendar control that has visual styles enabled will result in the selection range not painting correctly on the control.

Se aplica a

Consulte también: