Reputation: 1387
I developed a program that is operated by multiple computers connected to the same network, and as some of those computers use different DateTime formats, I converted the output DateTime to string in order to standardise it using the British format (dd/mm/yyyy hh:mm:ss).
However, when the output is displayed in DataGridView, it's not being sorted chronologically (the most recent ones should be on top) due to the fact the output is formatted as string, e.g.: 30/06/2015 13:00:00 is displayed above 03/07/2015 13:00:00 as '3' is the 1st character of the 1st string and it's greater than '0', 1st character of the 2nd string.
My question is how do I set my DataGridView to sort those strings in chronological order?
Any help will be much appreciated.
Upvotes: 0
Views: 872
Reputation: 100
You should not convert it to String. You should use date time object only and format it using DefaultCellStyle.Format
Upvotes: 4