Dot-Net

.NET WinForms 的時間選擇器?

  • December 28, 2018

Windows 表單有很多好的日期選擇器,但我還沒有找到任何好的時間選擇器。

有什麼建議?


編輯

我想我應該更清楚。我說的是一個更好看的時間選擇器。我們使用商業控制套件,預設時間選擇器看起來不合適,因為它太簡單了。

DatePicker 有一個屬性 Format 可以設置為 Time。請務必將 ShowUpDown 設置為 True。

Infragistics 在 Winforms 中非常流行,並且可以選擇 DateTimePicker。

…將 MaskInput 設置為 {time} 應該會得到您正在尋找的行為。如果只設置了 FormatString 屬性,那麼只有在控制項處於編輯模式(游標在控制項中)時才會顯示時間。

來自<http://forums.infragistics.com/forums/t/4172.aspx>

你的意思是,與標準的 Winforms DateTimePicker 不同?

this.dateTimePicker1.CustomFormat = "hh:mm tt";
this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker1.ShowUpDown = true;

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
   MessageBox.Show(dateTimePicker1.Value.TimeOfDay.ToString());
}

引用自:https://stackoverflow.com/questions/1046268