Freigeben über


MonthCalendar.SelectionEnd Eigenschaft

Definition

Ruft das Enddatum des ausgewählten Datumsbereichs ab oder legt es fest.

public:
 property DateTime SelectionEnd { DateTime get(); void set(DateTime value); };
[System.ComponentModel.Browsable(false)]
public DateTime SelectionEnd { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.SelectionEnd : DateTime with get, set
Public Property SelectionEnd As DateTime

Eigenschaftswert

A DateTime , der das letzte Datum im Auswahlbereich angibt.

Attribute

Ausnahmen

Der Datumswert ist kleiner als der MinDate Wert.

- oder -

Der Datumswert ist größer als der MaxDate Wert.

Beispiele

Im folgenden Codebeispiel wird die Verwendung der SelectionStart Eigenschaften veranschaulicht SelectionEnd . Zum Ausführen des Beispiels fügen Sie den folgenden Code in ein Formular ein, das ein Steuerelement mit dem MonthCalendar Namen MonthCalendar1enthält, und rufen Sie die ShowAWeeksVacationOneMonthFromToday Methode aus dem Konstruktor oder Load der Ereignisbehandlungsmethode des Formulars auf.

// Computes a week one month from today.
void ShowAWeeksVacationOneMonthFromToday()
{
   DateTime today = this->MonthCalendar1->TodayDate;
   DateTime vacationStart = today.AddMonths(1);
   DateTime vacationEnd = vacationStart.AddDays(7);

   // Select the week using SelectionStart and SelectionEnd.
   this->MonthCalendar1->SelectionStart = vacationStart.AddDays(-1);
   this->MonthCalendar1->SelectionEnd = vacationEnd.AddDays(-1);
}
// Computes a week one month from today.
private void ShowAWeeksVacationOneMonthFromToday()
{
    DateTime today = this.MonthCalendar1.TodayDate;
    DateTime vacationStart = today.AddMonths(1);
    DateTime vacationEnd = vacationStart.AddDays(7);

    // Select the week using SelectionStart and SelectionEnd.
    this.MonthCalendar1.SelectionStart = vacationStart.AddDays(-1);
    this.MonthCalendar1.SelectionEnd = vacationEnd.AddDays(-1);
}

' Computes a week one month from today.
Private Sub ShowAWeeksVacationOneMonthFromToday()
    Dim today As Date = monthCalendar1.TodayDate
    Dim vacationStart = today.AddMonths(1)
    Dim vacationEnd = vacationStart.AddDays(7)

    Me.monthCalendar1.SelectionStart = vacationStart.AddDays(-1)
    Me.monthCalendar1.SelectionEnd = vacationEnd.AddDays(-1)
End Sub

Hinweise

Wenn Sie den Wert der SelectionEnd Eigenschaft auf ein Datum festlegen, das vor dem aktuellen Wert der SelectionStart Eigenschaft liegt, SelectionStart wird automatisch gleich festgelegt SelectionEnd.

Wenn Sie ein Datum festlegen, das SelectionEnd bewirkt, dass die Auswahl die von der MaxSelectionCount Eigenschaft angegebene Anzahl von Tagen überschreitet, wird der Wert SelectionStart der Eigenschaft angepasst; SelectionStart wird automatisch festgelegt, sodass die ausgewählte Anzahl von Tagen gleich MaxSelectionCountist.

Hinweis

MaxSelectionCount stellt die Anzahl der Tage in der Auswahl dar, nicht die Differenz zwischen SelectionStart und SelectionEnd. Wenn z. B MaxSelectionCount . "7" (Standardeinstellung) ist, SelectionStart können sie SelectionEnd maximal sechs Tage auseinander liegen.

Hinweis

Das Festlegen des SelectionRangeMonthCalendar Steuerelements mit aktivierten visuellen Formatvorlagen führt dazu, dass der Auswahlbereich nicht ordnungsgemäß auf dem Steuerelement strich.

Gilt für:

Weitere Informationen