Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Ruft das Anfangsdatum des ausgewählten Datumsbereichs ab oder legt dieses fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Property SelectionStart As DateTime
'Usage
Dim instance As MonthCalendar
Dim value As DateTime
value = instance.SelectionStart
instance.SelectionStart = value
public DateTime SelectionStart { get; set; }
public:
property DateTime SelectionStart {
DateTime get ();
void set (DateTime value);
}
/** @property */
public DateTime get_SelectionStart ()
/** @property */
public void set_SelectionStart (DateTime value)
public function get SelectionStart () : DateTime
public function set SelectionStart (value : DateTime)
Eigenschaftenwert
Eine DateTime, die das erste Datum im Auswahlbereich angibt.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Der Datumswert ist kleiner als MinDate. - oder - Der Datumswert ist größer als MaxDate. |
Hinweise
Wenn Sie den Wert der SelectionStart-Eigenschaft auf ein Datum festlegen, das nach dem aktuellen Wert der SelectionEnd-Eigenschaft liegt, wird SelectionEnd automatisch auf den Wert von SelectionStart festgelegt.
Wenn Sie ein Datum in SelectionStart festlegen, das die mit der MaxSelectionCount-Eigenschaft festgelegte Anzahl von Tagen überschreitet, wird der Wert von SelectionEnd angepasst. SelectionEnd wird automatisch so festgelegt, dass die ausgewählte Anzahl von Tagen gleich MaxSelectionCount ist.
Hinweis
MaxSelectionCount stellt die Anzahl von Tagen in der Auswahl dar, und nicht die Differenz zwischen SelectionStart und SelectionEnd. Wenn z. B. MaxSelectionCount 7 (der Standardwert) ist, können SelectionStart und SelectionEnd höchstens sechs Tage auseinanderliegen.
Hinweis
Durch Festlegen des SelectionRange für ein MonthCalendar-Steuerelement mit aktivierten visuellen Stilen wird der Auswahlbereich im Steuerelement nicht korrekt gezeichnet.
Beispiel
Im folgenden Codebeispiel wird die Verwendung der SelectionStart-Eigenschaft und der SelectionEnd-Eigenschaft veranschaulicht. Zum Ausführen des Beispiels fügen Sie folgenden Code in ein Formular ein, das ein MonthCalendar-Steuerelement mit der Bezeichnung MonthCalendar1 enthält, und rufen Sie die ShowAWeeksVacationOneMonthFromToday-Methode im Konstruktor oder in der Load-Ereignisbehandlungsmethode des Formulars auf.
' 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
// 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.
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.get_TodayDate();
int vacationMonth = 1;
if (today.get_Month() < 12) {
vacationMonth = today.get_Month() + 1;
}
// Select the week using SelectionStart and SelectionEnd.
this.monthCalendar1.set_SelectionStart(
new System.DateTime(today.get_Year(),
vacationMonth, today.get_Day() - 1));
this.monthCalendar1.set_SelectionEnd(
new System.DateTime(today.get_Year(),
vacationMonth, today.get_Day() + 6));
} //ShowAWeeksVacationOneMonthFromToday
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
.NET Compact Framework
Unterstützt in: 2.0
Siehe auch
Referenz
MonthCalendar-Klasse
MonthCalendar-Member
System.Windows.Forms-Namespace
MonthCalendar.SelectionRange-Eigenschaft
MonthCalendar.SelectionEnd-Eigenschaft
SetSelectionRange