There is a DataType in the column. Have you tried setting the DateTime value?
var accTable = new DataTable(); var columnSpec = new DataColumn("Date"); columnSpec.DataType = typeof(DateTime); accTable.Columns.Add(columnSpec);
Of course, you can do this on one line (thanks to BFree):
accTable.Columns.Add("Date",typeof(DateTime));
You bind this DataTable to a DataGridView , and then set the SortMode property for each column in the view:
column.SortMode = DataGridViewColumnSortMode.Automatic;
I had code that did all of this, but I converted it to use types with a null value (including DateTime fields), and it doesn't work as I expected. If I can return it again, I will update this answer.
source share