寻找可以表示时间值的WinForms控件

时间:2012-04-10 02:51:28

标签: c# winforms timer controls

我正在寻找可以代表以下值的第三方开源或商业WinForms控件:

任务的总持续时间 经过的时间。
剩余时间。

找不到一个。

2 个答案:

答案 0 :(得分:4)

System.Diagnostic命名空间中有一个Stopwatch Class,您应该可以使用它来创建自己的控件。

  

秒表实例可以测量一个间隔的经过时间,或多个间隔的经过时间总和。在典型的秒表场景中,您调用Start方法,然后最终调用Stop方法,然后使用Elapsed属性检查已用时间。

答案 1 :(得分:0)

Infragistics在Winforms中非常流行,并且可以选择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).
来自http://forums.infragistics.com/forums/t/4172.aspx

但我认为第三方将是付费的。

如果您正在寻找Windows内部控件,则DatePicker具有可以设置为Time的属性Format。务必将ShowUpDown设置为True。

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

.......

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