MonthCalendar.TodayDate Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the value that is used by MonthCalendar as today's date.
public:
property DateTime TodayDate { DateTime get(); void set(DateTime value); };
public DateTime TodayDate { get; set; }
member this.TodayDate : DateTime with get, set
Public Property TodayDate As DateTime
Property Value
A DateTime representing today's date. The default value is the current system date.
Exceptions
The value is less than the minimum allowable date.
-or-
The value is greater than the maximum allowable date.
Examples
The following code example demonstrates how to use the SelectionStart, TodayDate and SelectionEnd properties. 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()
{
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
Remarks
By default, the TodayDate property returns the current system date, and the TodayDateSet property is false
. Setting the TodayDate property sets the TodayDateSet property to true
and, from that point, the value returned by the TodayDate property is the one the user sets.
Applies to
See also
Pripomienky
https://aka.ms/ContentUserFeedback.
Pripravujeme: V priebehu roka 2024 postupne zrušíme službu Problémy v službe GitHub ako mechanizmus pripomienok týkajúcich sa obsahu a nahradíme ju novým systémom pripomienok. Ďalšie informácie nájdete na stránke:Odoslať a zobraziť pripomienky pre