DateTimePicker.ShowCheckBox DateTimePicker.ShowCheckBox DateTimePicker.ShowCheckBox DateTimePicker.ShowCheckBox Property

定義

取得或設定值,指出核取方塊是否顯示在選取的日期左邊。Gets or sets a value indicating whether a check box is displayed to the left of the selected date.

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,否則為 falsetrue if a check box is displayed to the left of the selected date; otherwise, false. 預設為 falseThe default is false.

範例

下列程式碼範例會建立DateTimePicker控制項的新實例, 並將它初始化。The following code example creates an new instance of a DateTimePicker control and initializes it. 已設定控制項CustomFormat的屬性。The control's CustomFormat property is set. 此外, ShowCheckBox也會設定屬性, 讓控制項CheckBox顯示, 並ShowUpDown設定屬性, 讓控制項顯示為微調按鈕控制項 (也稱為上下按鈕控制項)。Also, the ShowCheckBox property is set so that the control displays a CheckBox, and the ShowUpDown property is set so that the control is displayed as a spin button control (also known as an up-down control).

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 'CreateMyDateTimePicker

備註

當屬性設定為true時, 會在控制項中的日期左邊顯示覆選框。 ShowCheckBoxWhen the ShowCheckBox property is set to true, a check box is displayed to the left of the date in the control. 選取此核取方塊時, 可以更新日期/時間值。When the check box is selected, the date/time value can be updated. 清除核取方塊時, 將無法變更日期/時間值。When the check box is cleared, the date/time value is unable to be changed.

適用於