DateTimePicker.MinDate 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置可在控件中选择的最小日期和时间。
public:
property DateTime MinDate { DateTime get(); void set(DateTime value); };
public DateTime MinDate { get; set; }
member this.MinDate : DateTime with get, set
Public Property MinDate As DateTime
属性值
可在控件中选择的最小日期和时间。 默认值为 1/1/1753 00:00:00
。
例外
示例
下面的代码示例创建控件的新实例 DateTimePicker 并对其进行初始化。 控件的 CustomFormat 属性已设置。 此外, ShowCheckBox 设置 属性以便控件显示 一个 CheckBox,并 ShowUpDown 设置 属性,使控件显示为旋转按钮控件 (也称为) 向上向下控件。
public:
void CreateMyDateTimePicker()
{
// Create a new DateTimePicker control and initialize it.
DateTimePicker^ dateTimePicker1 = gcnew DateTimePicker;
// Set the MinDate and MaxDate.
dateTimePicker1->MinDate = DateTime(1985,6,20);
dateTimePicker1->MaxDate = DateTime::Today;
// Set the CustomFormat string.
dateTimePicker1->CustomFormat = "MMMM dd, yyyy - dddd";
dateTimePicker1->Format = DateTimePickerFormat::Custom;
// Show the CheckBox and display the control as an up-down control.
dateTimePicker1->ShowCheckBox = true;
dateTimePicker1->ShowUpDown = true;
}
public void CreateMyDateTimePicker()
{
// Create a new DateTimePicker control and initialize it.
DateTimePicker dateTimePicker1 = new DateTimePicker();
// Set the MinDate and MaxDate.
dateTimePicker1.MinDate = new DateTime(1985, 6, 20);
dateTimePicker1.MaxDate = DateTime.Today;
// Set the CustomFormat string.
dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd";
dateTimePicker1.Format = DateTimePickerFormat.Custom;
// Show the CheckBox and display the control as an up-down control.
dateTimePicker1.ShowCheckBox = true;
dateTimePicker1.ShowUpDown = true;
}
Public Sub CreateMyDateTimePicker()
' Create a new DateTimePicker control and initialize it.
Dim dateTimePicker1 As New DateTimePicker()
' Set the MinDate and MaxDate.
dateTimePicker1.MinDate = New DateTime(1985, 6, 20)
dateTimePicker1.MaxDate = DateTime.Today
' Set the CustomFormat string.
dateTimePicker1.CustomFormat = "MMMM dd, yyyy - dddd"
dateTimePicker1.Format = DateTimePickerFormat.Custom
' Show the CheckBox and display the control as an up-down control.
dateTimePicker1.ShowCheckBox = True
dateTimePicker1.ShowUpDown = True
End Sub