// Custom comparison logic for sorting
if Grid.Floats[ACol, ARow1] > Grid.Floats[ACol, ARow2] then
AResult := 1
else if Grid.Floats[ACol, ARow1] < Grid.Floats[ACol, ARow2] then
AResult := -1
else
AResult := 0;
It throws an exception when Result:=-1
Here my code:
function TForm.GridCustomCompare(Sender: TObject; AColumn, ARow1, ARow2: Integer; AData1, AData2: TTMSFNCDataGridCellValue; ALevel: Integer): Integer;
begin
// Custom comparison logic for sorting
if Grid.Ints[AColumn, ARow1] > Grid.Ints[AColumn, ARow2] then
Result := 1
else if Grid.Ints[AColumn, ARow1] < Grid.Ints[AColumn, ARow2] then
Result := -1
else
Result := 0;
end;
By the way: The parameter list of the function is different to the one in the manual…
function TForm1.TMSFNCDataGrid1CustomCompare(Sender: TObject; AColumn, ARow1,
ARow2: Integer; AData1, AData2: TTMSFNCDataGridCellValue;
ALevel: Integer): Integer;
begin
// Custom comparison logic for sorting
if TMSFNCDataGrid1.ValueToInteger(AData1) > TMSFNCDataGrid1.ValueToInteger(AData2) then
Result := 1
else if TMSFNCDataGrid1.ValueToInteger(AData1) < TMSFNCDataGrid1.ValueToInteger(AData2) then
Result := -1
else
Result := 0;
end;