DataGridView SortCompare Doesn't Fire

1.4k Views Asked by At

I'm using a DataViewGrid (.NET 4.0). Rows are added programmatically and one of the rows is, in reality, numerical. I would like to sort on that column. All the columns have SortMode=automatic; the grid's VirtualMode=false; there is no datasouce. I have an event:

 private void myDataGridView_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
    {

        if (e.Column.Index == 2)
        {
            e.SortResult = int.Parse(e.CellValue1.ToString()).CompareTo(int.Parse(e.CellValue2.ToString()));
            e.Handled = true;//pass by the default sorting
        }
    }

But the code never gets here. I click on the header over but nothing.

Any help is appreciated.

RON

0

There are 0 best solutions below