DateTimePicker.ShowUpDown 属性

定义

获取或设置一个值,该值指示是否使用数值调节钮控件(也称为 up-down 控件)调整日期/时间值。

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

属性值

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

注解

ShowUpDown当属性设置为true时,旋转按钮控件 (也称为向上控件) 而不是下拉日历,用于调整时间值。 可以通过单独选择每个元素并使用向上和向下按钮来更改值来调整日期和时间。

若要仅显示时间 DateTimePicker,请将 Format 属性设置为 Time,并将 ShowUpDown 属性设置为 true

适用于

另请参阅