Create a table:

DataTable table = new DataTable("Таблица"); 

header - the header of the "Date" column

Adding a column:

 table.Columns.Add(new DataColumn(header, typeof(DateTime))); 

When writing data of this type in this column 17:42:48 15-06-2016 my time is truncated.

I would like to make sure that the time is still displayed in the cell when viewed in a DataGrid and the table could be sorted by the "Date" column precisely by date and not by text value.

Tell me in which direction to look?

    1 answer 1

     dataGridView1.Columns[header].DefaultCellStyle.Format = "HH:mm:ss dd-MM-yyyy"; 

    Are you looking for this?

    • those. don't i need to set typeof (datetime)? - Sheldon
    • You need to set how to display it. Those. The default settings do not match your needs. So you just set your casting format to a string and the grid will substitute it for this cell. - Arheus