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 den Wert ab, der von MonthCalendar als aktuelles Datum verwendet wird, oder legt diesen fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Property TodayDate As DateTime
'Usage
Dim instance As MonthCalendar
Dim value As DateTime
value = instance.TodayDate
instance.TodayDate = value
public DateTime TodayDate { get; set; }
public:
property DateTime TodayDate {
DateTime get ();
void set (DateTime value);
}
/** @property */
public DateTime get_TodayDate ()
/** @property */
public void set_TodayDate (DateTime value)
public function get TodayDate () : DateTime
public function set TodayDate (value : DateTime)
Eigenschaftenwert
Eine DateTime, die das aktuelle Datum darstellt. Der Standardwert ist das aktuelle Systemdatum.
Ausnahmen
| Ausnahmetyp | Bedingung |
|---|---|
Der Wert ist kleiner als das kleinstmögliche Datum. - oder - Der Wert ist größer als das größtmögliche Datum. |
Hinweise
In der Standardeinstellung gibt die TodayDate-Eigenschaft das aktuelle Systemdatum zurück, und die TodayDateSet-Eigenschaft ist false. Wenn die TodayDate-Eigenschaft festgelegt wird, wird die TodayDateSet-Eigenschaft auf true festgelegt und der von der TodayDate-Eigenschaft zurückgegebene Wert ist von da an der vom Benutzer festgelegte Wert.
Beispiel
Im folgenden Codebeispiel wird die Verwendung der SelectionStart-Eigenschaft, der TodayDate-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
TodayDateSet
MonthCalendar.ShowToday-Eigenschaft