|
|
{ Move row up }
procedure TForm1.Button1Click(Sender: TObject);
var
PrevCol1, PrevCol2: string;
begin
if StringGrid1.Row = 1 then Exit;
with StringGrid1 do
begin
{ Saving cell values in previous row }
PrevCol1 := Cells[0, Row-1];
PrevCol2 := Cells[1, Row-1];
{ Changing cell values in previous row }
Cells[0, Row-1] := Cells[0, Row];
Cells[1, Row-1] := Cells[1, Row];
{ Saving cell values in curreent row }
Cells[0, Row] := PrevCol1;
Cells[1, Row] := PrevCol2;
{ Moving focus selection }
Row := Row - 1;
SetFocus;
end;
end;
|