DateTimePicker.ShowUpDown DateTimePicker.ShowUpDown DateTimePicker.ShowUpDown DateTimePicker.ShowUpDown Property

定義

取得或設定值,指出是否使用微調按鈕控制項 (也稱為上下按鈕控制項) 來調整日期/時間值。Gets or sets a value indicating whether a spin button control (also known as an up-down control) is used to adjust the date/time value.

public:
 property bool ShowUpDown { bool get(); void set(bool value); };
public bool ShowUpDown { get; set; }
member this.ShowUpDown : bool with get, set
Public Property ShowUpDown As Boolean

屬性值

如果使用微調按鈕控制項來調整日期/時間值則為 true,否則為 falsetrue if a spin button control is used to adjust the date/time value; 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.

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時, 微調按鈕控制項 (也稱為上下按鈕控制項), 而不是下拉式日曆, 用來調整時間值。 ShowUpDownWhen the ShowUpDown property is set to true, a spin button control (also known as an up-down control), rather than a drop-down calendar, is used to adjust time values. 您可以個別選取每個專案, 並使用 [上移] 和 [下移] 按鈕來變更值, 以調整日期和時間。The date and time can be adjusted by selecting each element individually and using the up and down buttons to change the value.

若只要顯示中DateTimePicker的時間, 請FormatShowUpDown屬性設Time為, 並將屬性true設定為。To display only time in a DateTimePicker, set the Format property to Time, and the ShowUpDown property to true.

適用於

另請參閱