Time only pickers for .NET WinForms?

2019-06-15 05:13发布

There are tons of good date pickers out there for Windows forms, but I have yet to find any good time only pickers.

Any suggestions?


EDIT

I guess I should be more clear. I am talking about a nicer looking time picker. We use a commercial control suite, and the default time picker looks out of place because it is so plain.

6条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-06-15 05:20
  1. Add a DateTimePicker control
  2. Set the property 'Format' to 'Time'
  3. Set the property 'Custom Format' to 'hh:mm:ss'
  4. Set the property 'ShowUpDown' to 'True'

That's it

查看更多
一纸荒年 Trace。
3楼-- · 2019-06-15 05:21

Just to elaborate on Michael Petrotta's response the code

this.dateTimePicker1.CustomFormat = "hh:mm";

is for the 12 hour format, where as the code below is for the 24 hr format

this.dateTimePicker1.CustomFormat = "HH:mm";
查看更多
\"骚年 ilove
4楼-- · 2019-06-15 05:35

Has been years of this thread but i modified the open source time-picker on sourceforge: https://sourceforge.net/projects/time-picker/ to make a dll, just drag from explorer and drop to toolbox and you are ready to go

visual studio solution: https://drive.google.com/file/d/1rfV8CXoyUxPuOHQK9dYcZj5WSCSF5gIz/view?usp=sharing

on debug folder is the dll

查看更多
Animai°情兽
5楼-- · 2019-06-15 05:41

You mean, as opposed to the standard 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());
}
查看更多
我只想做你的唯一
6楼-- · 2019-06-15 05:45

DatePicker has a property Format that can be set to Time. Be sure to set ShowUpDown to True.

Infragistics is pretty popular for Winforms and has the option for its DateTimePicker.

... setting the MaskInput to {time} should get the behavior you are looking for. If you only set the FormatString property, the the time will display only when the control is in edit mode (when the cursor is in the control).

from http://forums.infragistics.com/forums/t/4172.aspx

查看更多
Ridiculous、
7楼-- · 2019-06-15 05:47

Here is a link to an open source time-picker on sourceforge: https://sourceforge.net/projects/time-picker/

C# Winforms TimePicker

查看更多
登录 后发表回答