unit Unit6; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, AdvUtil, Vcl.StdCtrls, Vcl.Grids, AdvObj, BaseGrid, AdvGrid; type TForm6 = class(TForm) AdvStringGrid1: TAdvStringGrid; Button1: TButton; Button3: TButton; Button4: TButton; Button5: TButton; procedure Button1Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure Button5Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form6: TForm6; implementation {$R *.dfm} procedure TForm6.Button1Click(Sender: TObject); begin AdvStringGrid1.Cells[0, 1] := ‘小李飞刀‘; AdvStringGrid1.Cells[1, 1] := ‘1111111‘; AdvStringGrid1.Cells[2, 1] := ‘2222222‘; AdvStringGrid1.Cells[0, 2] := ‘火云邪神‘; AdvStringGrid1.Cells[1, 2] := ‘33333333‘; AdvStringGrid1.Cells[2, 2] := ‘44444444‘; end; procedure TForm6.Button3Click(Sender: TObject); begin //删除所有数据(剩下空行) AdvStringGrid1.ClearRows(1, AdvStringGrid1.RowCount - 1); end; procedure TForm6.Button4Click(Sender: TObject); begin //仅清空选中行内容,只剩下空行 AdvStringGrid1.Rows[AdvStringGrid1.Row].Clear; end; procedure TForm6.Button5Click(Sender: TObject); begin //删除行,也没有空行了,整行完全消失: AdvStringGrid1.RemoveRows(AdvStringGrid1.Row, 1); end; end.
时间: 2024-10-12 19:01:53