没太理解,是这个意思码?var Form1: TForm1;implementation{$R *.dfm} var myrow: integer = 1;procedure TForm1.Button1Click(Sender: TObject); var i: integer; begin if myrow <= 5 then begin stringgrid1.Cells[0, myrow] := inttostr(myrow); stringgrid1.Cells[1, myrow] := inttostr(myrow); end else begin for i := 1 to 5 - 1 do begin stringgrid1.Cells[0, i] := stringgrid1.Cells[0, i + 1]; stringgrid1.Cells[1, i] := stringgrid1.Cells[0, i + 1]; end; stringgrid1.Cells[0, 5] := inttostr(myrow); stringgrid1.Cells[1, 5] := inttostr(myrow); end; Inc(myrow); end;
Form1: TForm1;implementation{$R *.dfm}
var
myrow: integer = 1;procedure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
if myrow <= 5 then
begin
stringgrid1.Cells[0, myrow] := inttostr(myrow);
stringgrid1.Cells[1, myrow] := inttostr(myrow);
end
else
begin
for i := 1 to 5 - 1 do
begin
stringgrid1.Cells[0, i] := stringgrid1.Cells[0, i + 1];
stringgrid1.Cells[1, i] := stringgrid1.Cells[0, i + 1];
end;
stringgrid1.Cells[0, 5] := inttostr(myrow);
stringgrid1.Cells[1, 5] := inttostr(myrow);
end;
Inc(myrow);
end;
倒着添加,正着存储!