DateTimePicker.ShowUpDown 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定值,指出是否使用微調按鈕控制項 (也稱為上下按鈕控制項) 來調整日期/時間值。
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
,否則為 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
。