Showing time in DataGridView column

To show time in a DataGridView column set the column type to DataGridViewTextBoxColumn.
Set the columns DefaultCellStyle Format to ‘t’. You can do this in the designer or use the following code:

myGridView.Columns[0].DefaultCellStyle.Format = “t”; //0 is the required column, change if needed.

Now you can assign a DateTime to the cell value and time will show in the users preferred format (‘t’).

Lastest update in April 2012, inital post in April 2012

Write a comment

I appreciate comments, suggestions, compliments etc. Unfortunately I have no time to reply to them. Useful input will be used for sure!