.NET WinForms仅限时间选择器?

Dan*_*olt 14 .net time controls winforms

对于Windows窗体,有很多好的日期选择器,但我还没有找到任何好时光只有选择器.

有什么建议?


编辑

我想我应该更清楚.我说的是一个更好看的时间选择器.我们使用商业控制​​套件,默认的时间选择器看起来不合适,因为它非常简单.

Mic*_*tta 19

你的意思是,而不是标准的Winforms DateTimePicker?

this.dateTimePicker1.CustomFormat = "hh:mm tt";
this.dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.dateTimePicker1.ShowUpDown = true;
Run Code Online (Sandbox Code Playgroud)

...

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


blu*_*blu 16

DatePicker具有可以设置为Time的属性Format.务必将ShowUpDown设置为True.

Infragistics在Winforms中非常流行,并且可以选择DateTimePicker.

...将MaskInput设置为{time}应该可以获得您正在寻找的行为.如果仅设置FormatString属性,则仅当控件处于编辑模式时(光标位于控件中时)才会显示时间.

来自http://forums.infragistics.com/forums/t/4172.aspx


小智 8

只是详细阐述Michael Petrotta对代码回应

this.dateTimePicker1.CustomFormat = "hh:mm";
Run Code Online (Sandbox Code Playgroud)

是12小时格式,其中下面的代码是24小时格式

this.dateTimePicker1.CustomFormat = "HH:mm";
Run Code Online (Sandbox Code Playgroud)


小智 5

  1. 添加 DateTimePicker 控件
  2. 将属性“格式”设置为“时间”
  3. 将属性“自定义格式”设置为“hh:mm:ss”
  4. 将属性“ShowUpDown”设置为“True”

就是这样