1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
function CellCompare(const AStringGrid: TStringGrid;
const SortOrder: TSortOrder;
const Column, Index1, Index2: Integer): Integer;
begin
// Si vous voulez ne pas tenir compte de la casse, utilisez AnsiCompareText
// au lieu de AnsiCompareStr
with AStringGrid do
begin
{ test non concluant :
if Cells[Column, Index1] = Cells[Column, Index2] then
begin
Result := 0;
exit;
end; }
{Si cellule vide (Test non concluant !) :
if Trim(Cells[Column, Index1]) = '' then
begin
Result := -1;
Exit;
end;
if Trim(Cells[Column, Index2]) = '' then
begin
Result := 1;
Exit;
end;
}
case SortOrder of
//Modifier pour comparer des chiffres :
soUp: result:= StrToIntDef(Cells[Column, Index1], -MaxInt) - StrToIntDef(Cells[Column, Index2], -MaxInt);
soDown: result:= StrToIntDef(Cells[Column, Index2], MaxInt) - StrToIntDef(Cells[Column, Index1], MaxInt);
else
result:= 0;
end;
end;
end; |
Partager