Is there any CustomFormat for showing the millisecond in DateTimePicker

I wants to show the millisecond in the DateTimePicker.So the customer can change the millisecond value also.

Is there any format by which i can show the millisecond in datetimepicker.

Regards

Yogesh



Answer this question

Is there any CustomFormat for showing the millisecond in DateTimePicker

  • Count Zero

    > Is there any format by which i can show the millisecond in datetimepicker

    AFAIK the answer is no. The supported formats are described in the MSDN docmentation for the CustomFormat property. You can't use it for anything more precise than a second.

    This control wraps the native Windows DateTimePicker control implemented in ComCtl32.dll and only supports format strings supported by that control - the .NET "f" specifier for fractions of a second is not supported.


  • Jason S.

    There are two issues here. The first issue is getting a string representation of DateTime to include the milliseconds. You can't display the milliseconds directly but you can use the "f" format specifier to include the fractional seconds. You'll need to combine this the other specifiers to build the full string. The second issue is the DTP itself. I believe the DTP is somewhat flaky when it comes to displaying values. I believe it pretty much ignores custom formatting under some common situations. I believe there was a post about it a while back. Nevertheless in theory you can set it by simply using the ToString() method of the DateTime with the appropriate format specifiers. However an issue that you'll have to overcome is that you really should build the string using the culture information for the UI which is non-trivial to say the least. So if you want to show milliseconds then you'll probably have to settle for always showing it in some neutral culture like English or something.

    Michael Taylor - 5/10/06


  • Is there any CustomFormat for showing the millisecond in DateTimePicker