Сортировка столбцов в StringGrid
Автор: http://www.sources.ru
procedure GridSort(StrGrid: TStringGrid; NoColumn: Integer);
var
Line, PosActual: Integer;
Row: TStrings;
begin
Renglon := TStringList.Create;
for Line := 1 to StrGrid.RowCount - 1 do
begin
PosActual := Line;
Row.Assign(TStringlist(StrGrid.Rows[PosActual]));
while True do
begin
if (PosActual = 0) or (StrToInt(Row.Strings[NoColumn - 1]) >=
StrToInt(StrGrid.Cells[NoColumn - 1, PosActual - 1])) then
Break;
StrGrid.Rows[PosActual] := StrGrid.Rows[PosActual - 1];
Dec(PosActual);
end;
if StrToInt(Row.Strings[NoColumn - 1]) < StrToInt(StrGrid.Cells[NoColumn -
1, PosActual]) then
StrGrid.Rows[PosActual] := Row;
end;
Renglon.Free;
end;
|