用数组
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
//****************************************//
ckbox: array [1..10] of TCheckBox;
//****************************************//
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
//****************************************//
for i:=1 to 10 do
begin
ckbox:=Tcheckbox.Create(Form1);
ckbox.ParentWindow:=form1.Handle;
ckbox.Caption:='ckbox'+inttostr(i);
ckbox.Top :=i*20;
ckbox.Left:=0;
ckbox.Show;
end;
//****************************************//
end;
end.
判断只要遍历数组就可以了