Defines the selected date, or the first date of a range; Null when there is none.
Get
| C# | object Date = object.Value; |
| VB.NET | Date = object.Value As Object |
| C++ | _variant_t Date = object->Value; _variant_t Date = object->GetValue(); |
| C | HRESULT object->get_Value(VARIANT* Date); |
Put
| C# | object object.Value = Date; |
| VB.NET | object.Value = Date As Object |
| C++ | _variant_t object->Value = Date; void object->PutValue(const _variant_t& Date); |
| C | HRESULT object->put_Value(VARIANT Date); |
object
Date
Defines the selected date, or the first date of a range; Null when there is none.
The Value property defines the selected date of the month calendar control. Its time is always 00:00:00. A new control has no selected date and the value is Null. p Setting Null removes the selection. In .NET, Null is DBNull.Value; null (Nothing) also removes the selection. p In range selection mode (SelectionMode), the value is the first date of the range (RangeStart); setting it selects a range of one day. p A date outside the range defined by MinDate and MaxDate causes an error. When the value changes, the control raises the ValueChanged event. The date that has the keyboard focus is a separate setting (FocusedDate).
private void ShowSelection() {
string text = "Selected: (none)";
if (sftCalendar.SelectionMode == SftDateSelectionModeConstants.selectionSftDateRange) {
if (sftCalendar.RangeStart is DateTime) {
DateTime start = (DateTime)sftCalendar.RangeStart;
DateTime end = sftCalendar.RangeEnd is DateTime ? (DateTime)sftCalendar.RangeEnd : start;
text = "Selected: " + FormatLongDate(start) + " - " + FormatLongDate(end);
}
} else if (sftCalendar.Value is DateTime)
text = "Selected: " + FormatLongDate((DateTime)sftCalendar.Value);
labelSelection.Text = text;
}
private void sftCalendar_ValueChanged(object sender, EventArgs e) {
ShowSelection();
}
Private Sub ShowSelection()
Dim selection As String = "Selected: (none)"
If sftCalendar.SelectionMode = SftDateSelectionModeConstants.selectionSftDateRange Then
If TypeOf sftCalendar.RangeStart Is Date Then
Dim start As Date = CDate(sftCalendar.RangeStart)
Dim [end] As Date = If(TypeOf sftCalendar.RangeEnd Is Date, CDate(sftCalendar.RangeEnd), start)
selection = "Selected: " & FormatLongDate(start) & " - " & FormatLongDate([end])
End If
ElseIf TypeOf sftCalendar.Value Is Date Then
selection = "Selected: " & FormatLongDate(CDate(sftCalendar.Value))
End If
labelSelection.Text = selection
End Sub
Private Sub sftCalendar_ValueChanged(sender As Object, e As EventArgs) Handles sftCalendar.ValueChanged, sftCalendar.RangeChanged
ShowSelection()See Also SftCalendar Object | Object Hierarchy | Values