You can register on the SortCompare
event, for example:
private void customSortCompare(object sender, DataGridViewSortCompareEventArgs e)
{
int a = int.Parse(e.CellValue1.ToString()), b = int.Parse(e.CellValue2.ToString());
// If the cell value is already an integer, just cast it instead of parsing
e.SortResult = a.CompareTo(b);
e.Handled = true;
}
...
yourGridview.SortCompare += customSortCompare;
...
I didn't check if that works, but you get the idea... ;)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…