DateTimePicker.ShowCheckBox 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示在选定日期的左侧是否显示一个复选框。
public:
property bool ShowCheckBox { bool get(); void set(bool value); };
public bool ShowCheckBox { get; set; }
member this.ShowCheckBox : bool with get, set
Public Property ShowCheckBox As Boolean
属性值
如果在选定日期的左边显示复选框,则为 true
;否则为 false
。 默认值为 false
。
示例
下面的代码示例创建控件的新实例 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
注解
当属性 ShowCheckBox 设置为 true
时,控件中日期左侧将显示一个复选框。 选中复选框后,可以更新日期/时间值。 清除复选框后,无法更改日期/时间值。