unit UnGrid1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, CheckLst, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
CheckListBox1: TCheckListBox;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
With StringGrid2 do
begin
Cells[0,0]:='行/列';
Cells[1,0]:='第1列';
Cells[2,0]:='第2列';
Cells[3,0]:='第3列';
Cells[4,0]:='第4列';
Cells[0,1]:='第一行';
Cells[1,1]:='Ge';
Cells[2,1]:='Hong';
Cells[3,1]:='is';
Cells[4,1]:='excellent';
Cells[0,2]:='第二行';
Cells[1,2]:='Song';
Cells[2,2]:='is';
Cells[3,2]:='';
Cells[4,2]:='BAD';
Cells[0,3]:='第三行';
Cells[1,3]:='Ge';
Cells[2,3]:='Hong';
Cells[3,3]:='is';
Cells[4,3]:='excellent';
Cells[0,4]:='第四行';
Cells[1,4]:='Song';
Cells[2,4]:='is';
Cells[3,4]:='';
Cells[4,4]:='BAD';
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
CheckListBox1.Items:=StringGrid2.Rows[StringGrid2.Row]
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
I,J,K:Integer;
begin
K:=0;
with StringGrid1 do
for I:=0 to ColCount-1 do
for J:=0 to RowCount-1 do
begin
K:=K+1;
Cells[I,J]:=IntToStr(K);
end;
end;
end.