DateTimePicker 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 DateTimePicker 类的新实例。
public:
DateTimePicker();
public DateTimePicker ();
Public Sub New ()
示例
下面的代码示例创建控件的新实例 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