开发者

Milliseconds value in a .NET DateTimePicker

I assumed that if "fff" works in DateTime.ToString then it would work in the custom format string for a DateTimePicker, but it appears this is not the case.

I understand that there may not be an immediate solution, but this really isn't a critical problem, so what is a viable alternative?

A few ideas I had:

  • Since the DateTimePicker onlyhas a pop down MonthCalender then I could use a DateTimePicker for the date and a masked textbox for the time, possibly with some simple event handling to make sure it's valid and acts a bit like a DateTimePicker.
  • Add an extra NumericUpDown afterwards for milliseconds. Won't look great but I can restrict to 3 digits and it would work very easily.
  • Do it properly and write a custom control 开发者_开发百科that inherits DateTimePicker and does some clever stuff.


There might be something available for free on the net:

http://www.codeproject.com/KB/cs/Time_Picker.aspx

You are correct, the DateTimePicker does not natively support it so you need to choose one of your ideas.


I ended up using a MaskedTextBox as it was quick and easy to put in the date/time format. I then added a simple button to the side which popped up a calendar in the same way that a DateTimePicker does.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜