开发者

use dateTimePIcker to set timer interval

I want to use dateTimerPicker Time format {mm:ss} and use it in timer.interval.

meaning converting the dateTimePicker value to double and开发者_StackOverflow社区 back again.

any thoughts ?


Use this:

timer.Interval = dateTimePicker.Value.TimeOfDay.TotalMilliseconds


timer.interval is in milliseconds. (mm * 60 + ss) * 1000 = time in milliseconds. Or easier is DateTime.TimeOfDay.TotalMilliseconds.

Perhaps it is also beter to use the TimeSpan object instead of the DateTime. Because you are not using the Date part of it. (Maybe for other reasons which I don't know)

You then can use the TimeSpan.TotalMilliseconds property.

TimeSpan on MSDN

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜