Good afternoon,
I am using a dataGridView to display some rows from a dataset, and with some calculated values also added in. The dataGrid view is populated using a DataView object, with some dataGridView fields populated using data that is calculated from other elements of the master DataSet.
In order to implement a total row at the bottom of the dataGridView, I have a checkbox field named "IsTotal". All "data" rows are set to false. The only one set to true is the total row, which will always be at the bottom.
I want the user to be able to sort the fields by click on the column headers, however the total row must always be at the bottom.
I have the solution half implemented by employing the Sorted event of the dataGridView.
In a nutshell, the event checks the field that the dataGridView has just been sorted by, and checks that it is not the "IsTotal" field (to prevent an infinate loop, caused by the event calling itself). If the dataGridView has just been sorted by a different field, it is resorted by the "IsTotal" field.
The sort works fine, but the dataGridView seems to loose it's old sorting completely. For example, if I sort by name and then sort by IsTotal, the rows should be sorted by IsTotal, and then by name. However, only the IsTotal field is sorted, the order after that sort has reverted back to it's default order.
Is there anyway to implement multi-level sorting programmatically?
Thanks.