Freigeben über


MonthCalendar.SelectionStart Eigenschaft

Definition

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

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

Eigenschaftswert

Ein DateTime Wert, der das erste Datum im Auswahlbereich angibt.

Attribute

Ausnahmen

Der Datumswert ist kleiner als MinDate.

- oder -

Der Datumswert ist größer als MaxDate.

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 SelectionStart Eigenschaft auf ein Datum festlegen, das später als der aktuelle Wert der SelectionEnd Eigenschaft ist, SelectionEnd wird automatisch gleich festgelegt SelectionStart.

Wenn Sie ein Datum festlegen, das SelectionStart bewirkt, dass die Auswahl die von der MaxSelectionCount Eigenschaft angegebene Anzahl von Tagen überschreitet, wird der Wert SelectionEnd der Eigenschaft angepasst; SelectionEnd 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