Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
650
DateTime columns for databinding at Runtime
posted

I have a grid and at runtime I set the DataSource property to a DataTable.

When it binds, if the table has a DateTime column in it, it only shows the date. How can I get it to display the hours, minutes, seconds, milliseconds?

Thanks

Parents
  • 69832
    Suggested Answer
    Offline posted

    UltraGridColumn exposes a Format property, which accepts any .NET date/time format specifier, for example, you could set it to "g", the token for the general date format. You can do this in response to the InitializeLayout event, by accessing the column from the e.Layout.Bands[n].Columns collection.

    Note that if you want to enable editing of the time components, you also need to set the MaskInput property, although that property does not recognize exactly the same specifiers. You can do something like this to get a basic date/time mask:

    EditorWithMask editor = column.Editor as EditorWithMask;
    string mask = editor.CalcDefaultDateMask(null, true) + " " + editor.CalcDefaultTimeMask(null);

Reply Children
No Data