There is a known Microsoft bug in DataGrid (or DataGridView, don't remember in which one, or may be in both...) and looks like you did not take any action to prevent it. The problem shows when you try to sort a grid by clicking on a DateTime column header and there are records with the SAME DateTime values.
Here is an example:
Lets say we have executions grid like this:
[GOOG] [Buy][100] [1/9/2009 9:00:00] [100L]
[GOOG] [Sell][10] [1/9/2009 9:10:00] [90L]
[GOOG] [Sell][20] [1/9/2009 9:10:00] [70L]
[GOOG] [Sell][70] [1/9/2009 9:15:00] [-]
Note that selling 10 and 20 happened at the same time.
If you sort backwards the grid by clicking on Time column you will se something like this:
[GOOG] [Sell][70] [1/9/2009 9:15:00] [-]
[GOOG] [Sell][10] [1/9/2009 9:10:00] [90L] <- (!)
[GOOG] [Sell][20] [1/9/2009 9:10:00] [70L] <- (!)
[GOOG] [Buy][100] [1/9/2009 9:00:00] [100L]
Note that data grid control sorted records with equal DateTime values incorrectly! And it creates lots of confusion.
Correct result should look like this:
[GOOG] [Sell][70] [1/9/2009 9:15:00] [-]
[GOOG] [Sell][20] [1/9/2009 9:10:00] [70L]
[GOOG] [Sell][10] [1/9/2009 9:10:00] [90L]
[GOOG] [Buy][100] [1/9/2009 9:00:00] [100L]
Here is a tip how to avoid it: When you add a record to the underneath data table, check last record's DateTime columns and if they are equal add 1 tick to the new record's DatTime column values. It wont affect how records are displayed but will guarantee that sorting back and forth will work correctly.
Cheers!
Comment