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

Definición

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

Valor de propiedad

DateTime que indica la primera fecha del intervalo de selección.A DateTime indicating the first date in the selection range.

Excepciones

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

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

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

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

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: