给你一段代码(不好意思,BCB的)
class TForm1 :public TForm
{
...TEdit * pEdit[10];
}void __fastcall TForm1::FormCreate()
{
for (int i = 0; i < 10; i++)
{
pEdit[i] = new TEdit(this);
pEdit[i]->Parent = this;
pEdit[i]->Top = i *40 + 5;
pEdit[i]->Left = 20;
pEdit[i]->Width = 100;
pEdit[i]->Height = 20;
...
}
}
class TForm1 :public TForm
{
...TEdit * pEdit[10];
}void __fastcall TForm1::FormCreate()
{
for (int i = 0; i < 10; i++)
{
pEdit[i] = new TEdit(this);
pEdit[i]->Parent = this;
pEdit[i]->Top = i *40 + 5;
pEdit[i]->Left = 20;
pEdit[i]->Width = 100;
pEdit[i]->Height = 20;
...
}
}
解决方案 »
- 关于Ftp的the system cannot find the file specified
- 到底怎么调用的请高手们赐教。。。。一个自定义过程
- %%%%%%%%%%如何实现SQL表的数据上传%%%%%%%%%%%%
- 100分 速求delphi源代码
- 关于数据库异常处理的问题
- delphi动态曲线问题
- 谁能发个 delphi7 的 帮助文档 中文版
- 请问哪里有Tras类下载?
- 怎样删除MDAC2.7(in win2000)?大家都不懂,还是不想回答,特急,重装MDAC2.6SP1不行!!!!!
- 动态生成的form能否保存?
- 谁有能将一个字符串的字符依次显示在窗体或其他控件上如PANEL!!!!???
- help me too
var
but:Tbutton;
begin
but:=Tbutton.create(self);
but.caption:='...';
but.left:=120;
..
but.onclick:=someTnotifyevent;
end;
btn:array[1..10] of TButton;
procedure TForm1.FormCreate(Sender:TObject);
var
i:integer;
begin
btn[1]:=Button1;
btn[2]:=Button2;
btn[3]:=Button3;
btn[4]:=Button4;
btn[5]:=Button5;
btn[6]:=Button6;
btn[7]:=Button7;
btn[8]:=Button8;
btn[9]:=Button9;
btn[10]:=Button10;
//定义事件
for i:=0 to 10 do
Btn[i].OnClick=BtnClick;//自己编写一个事件
end;
procedure TForm1.BtnClick(Sender:TObject);
begin
//首先要将Button1到Button10的Tag对应设置为1到10
//根据tag进行对应处理
case TButton(Sender).tag of
1: ;
2: ;
3: ;
4: ;
5: ;
6: ;
7: ;
8: ;
9: ;
10: ;
end;
end;
试一试,怎么样?不明白再说!
㈠、运行时生成可视控件:以下以TEdit 控件为例1.在Form的Public中定义TEdit控件Edit1:TEdit;2.在需要生成的地方加入以下代码:
Edit1:=TEdit.Create(Self);
Edit1.Parent:=Form1;
Edit1.Left ?:=20;
Edit1.Top :=20;
Edit1.Text :='Edit1 Text';
3.使用完毕后,释放分配的资源
if? Assigned(Edit1) then Edit1.Free; ?
var
fList : TList function CreateObj(aOwner: TComppentn) : TComponent;
begin
Result := TSpeedButton.Create(aOwner);
Result.Parnet := ..;
...
End; porcedure CreateButtonArray(aOwner : TComponent);
var
i : integer;
begin
for i := 0 to 100 do
fList.Add(CreateObj(aOwner));
End;
procedure FreeObj;
var
i : integer;
begin
if fList <> nil then
for i := 0 to fList.Count do
TSpeedButton(fList[i]).free;
End;
...... initialization
fList := TList.Create;
finalization
FreeObj;End.
Btn:TButton;
begin
Btn:=TButton.Create(Self); //创建一个组件
Btn.Parent:=self; //组件在主窗体上
Btn.Left:=...
Btn.Top:=...
Btn.OnClick:=aProcedure //映射Btn的单击事件
end;