2012-04-10 21 views
0

我找一個第三方的開源或商業的WinForms控制,可以表示以下值:尋找一個WinForms控制,可以表示時間值

任務的總時間。
已用時間。
剩餘時間。

一直未能找到一個。

+0

你有沒有試過這個定時器controll – 2012-04-10 02:57:23

+2

這很好的支持標準控件。一個普通的標籤,如果你只是想顯示它。一個MaskedEditBox,如果你想允許輸入或編輯。 – 2012-04-10 03:11:08

回答

4

System.Diagnostic命名空間有一個Stopwatch Class,你應該能夠使用它來創建自己的控制。

秒錶實例可以測量一個時間間隔的經過時間,或跨多個時間間隔的經過時間總和。在典型的秒錶方案中,您調用Start方法,然後最終調用Stop方法,然後使用Elapsed屬性檢查經過的時間。

+1

這正是我正在尋找的。也許我應該更好地說出這個問題。謝謝。 – 2012-04-10 06:33:44

+0

@Raheel很高興幫助 – 2012-04-10 16:32:14

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 inhouse控件DatePicker具有可以設置爲Time的屬性格式。一定要將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()); 
} 
相關問題