I am using just a simple DataGridView to hold a bunch of data (Funny that).
I have decimals in a particular column. But when it comes to ordering by that decimal column
Numeric types have a built in CompareTo function, which can be used as the SortResult of the SortCompare event.
private void dataGridView_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
{
if (e.Column.Index == 0)
{
e.SortResult = int.Parse(e.CellValue1.ToString()).CompareTo(int.Parse(e.CellValue2.ToString()));
e.Handled = true;
}
}
This is of course assuming you know the type that was put into the DataGridView to begin with.