I am having trouble determining when my DataGridView object is sorting (based on a column header click).
The idea is, in a large table, sorting the columns takes time, so I show a splash screen. When it is done sorting I want the splash screen dissapear.
What I had been doing was using the CellClick and Sorted events:
[code=c#]
private void myDGV_CellClick (object sender, DataGridViewCel lEventArgs e)
{
if (e.RowIndex == -1)
{//sorting
ShowSplash2(myD GV, "Sorting... ");
}
}
private void myDGV_Sorted(ob ject sender, EventArgs e)
{
HideSplash2(myD GV);
}
[/code]
This works really well, except for one problem. On checkbox columns that all have the same value (or possibly columns that are "unsortable "?) The CellClick event is triggered, but the Sorted event is not triggered. No sorting operation happens, so the event never triggers?
Does anyone know of a better way to determine if the gridview is starting to sort? I looked at the SortCompare event, but it never seemed to be fired at all. (I think it only gets fired when you call the .Sort() function)
Problem 2)
When you click the top of a column to sort the data, all the cellstyles disapear. anyone know how to keep the cellstyling the same between row sorting?
Edit: Using the CellFormatting event and state data kept inside a hidden row, i can keep changing the row style based on it.
The idea is, in a large table, sorting the columns takes time, so I show a splash screen. When it is done sorting I want the splash screen dissapear.
What I had been doing was using the CellClick and Sorted events:
[code=c#]
private void myDGV_CellClick (object sender, DataGridViewCel lEventArgs e)
{
if (e.RowIndex == -1)
{//sorting
ShowSplash2(myD GV, "Sorting... ");
}
}
private void myDGV_Sorted(ob ject sender, EventArgs e)
{
HideSplash2(myD GV);
}
[/code]
This works really well, except for one problem. On checkbox columns that all have the same value (or possibly columns that are "unsortable "?) The CellClick event is triggered, but the Sorted event is not triggered. No sorting operation happens, so the event never triggers?
Does anyone know of a better way to determine if the gridview is starting to sort? I looked at the SortCompare event, but it never seemed to be fired at all. (I think it only gets fired when you call the .Sort() function)
Problem 2)
When you click the top of a column to sort the data, all the cellstyles disapear. anyone know how to keep the cellstyling the same between row sorting?
Edit: Using the CellFormatting event and state data kept inside a hidden row, i can keep changing the row style based on it.
Comment