你这样做不是很麻烦?
创建edit
myedit : Tedit ;
myedit := Tedit.Create (self) ;
myedit.Parent := form1 ;
myedit.Top := 100 ;
myedit.Left := 200 ;
创建edit
myedit : Tedit ;
myedit := Tedit.Create (self) ;
myedit.Parent := form1 ;
myedit.Top := 100 ;
myedit.Left := 200 ;
解决方案 »
- 关于.dll文件的注册
- 程序写好以后编译通过并且可以过行,可是有时不稳定,所以进行单步调试,可是按F8提示错误,根本就无法进行下去,请看提示:
- QuickReport的問題,急,高手快來!!!!
- 救命呀!!!!!用NOKIA手机在超级终端中发短信时出现的问题,分不够再加,再加>>>>>>>>
- 求Web Services一份!!
- 当我对adoquery1 post 时,出现错误:Row cannot be located for updating。Some values may have been changed since it was last read.
- 十万火急!高手帮忙看一下代码哪里有错误!分少请见谅~!
- ado控件怎样连接excel文档
- 散分!!!回到CSDN!!
- 怎么专家分少了??????
- 高分求解 : 如何封装ServerSocket 为 OCX (想在VB下使用)
- 我的问题都很菜啊,呜呜2
Edit:TEdit;
begin
//把属性值存下来
Edit:=TEdit.Create(self);
Edit.Parent:=Self;
Edit.Left:=x;
Edit.Top:=y;
Edit.Height:=...
Edit.Width;=...
Edit.OnClick:=MyClick;
....
Edit.Show;end;procedure MyClick(Sender:TObject);
begin
//.....
end;
其它同上。
var i:integer;
Edit:TEdit;
begin //以Tag为标准.
for i:=0 to ListBox1.Items.Count-1 do
begin
Edit:=TEdit.Create(self);
Edit.Name:='Edit'+ListBox1.Items.Strings[i];
Edit.Parent:=self;
Edit.Left:=i*60;
Edit.Top:=i*5;
Edit.Tag:=strtoint(ListBox1.Items.Strings[i]);
end;
end;procedure TForm1.Button2Click(Sender: TObject); //查看组件数
var i,n:integer;
str,str1:string;
begin
n:=0;
str:='';
showmessage('组件数:'+inttostr(self.ComponentCount));
for i:=0 to self.ComponentCount-1 do
begin
if self.Components[i].ClassName='TEdit' then
begin
n:=n+1;
str:=str+' '+self.Components[i].Name;
case self.Components[i].Tag of
100: begin ...你要对这个控件做的事.. end;
111: begin ...你要对这个控件做的事.. end;
{ ..........}
end;
end;
end;
showmessage('TEdit组件数:'+Inttostr(n));
showmessage(str);
end;
{ 此例已测试过. }
var SA:array[0..100] of TLabel;//数量自己定义
SS:array[0..100] of TEdit;
begin SA[0]:=TLabel.Create(self);
SA[0].Parent:=Form1;
SA[0].Caption:='ok';
SS[0]:=TEdit.Create(self);
ss[0].Parent:=Form1;
ss[0].Left:=200;end;
var
edt:array of TEdit;
lbl:array of Tlabel;
i,iCount:integer;
begin
iCount:= table1.FieldCount;
setlength(edt,iCount);
setlength(lbl,iCount);
for i:=0 to iCount-1 do
begin lbl[i]:=Tlabel.Create(self);
lbl[i].Parent := form1;
lbl[i].Left := 90;
lbl[i].Top := i*30+50;
lbl[i].Caption := table1.Fields[i].FieldName; edt[i]:=TEdit.Create(self);
edt[i].Parent := form1;
edt[i].left := 200;
edt[i].top:=i*30+50;
edt[i].Text := '';
end;
end;
var lab : array of TLabel;
edt : array of TEdit;
arrCtlno : integer;
begin
arrCtlno := 10; //每种控件生成10个
SetLength(lab, arrCtlno);
SetLength(edt, arrCtlno); lab[no] := TLabel.Create(self);
edt[no] := TEdit.Create(self); lab[no].Parent := Form1;
lab[no].Top := 10;
lab[no].Left := 30;
lab[no].Width := 70;
lab[no].Font.Style := [fsBold];
lab[no].Caption := IntToStr(service_no);
lab[no].Visible := true; edt[no].Parent := Form1;
edt[no].Text := 'xxxxxxxxxxxxx';
edt[no].Top := 5;
edt[no].Left := 100;
edt[no].Width := 100;
edt[no].Visible := true;
end;
comcount:=comcount+1;
tt.Name:='compo'+inttostr(comcount); //以compo+序号来命名控件
tt.Top:=10+(j mod 7)*(44+5);
tt.Left:=30+((j mod 21) div 7)*220;
tt.Caption:='compo'+inttostr(comcount);//创建DBEDIT
dd:=tdbedit.Create(self);
comcount:=comcount+1;
dbcount:=dbcount+1;
dd.Name:='compo'+inttostr(comcount); //以compo+序号来命名控件
dd.Width:=170;
dd.DataSource:=dm1.datasource1;
Edit:TEdit;
begin
Edit:=TEdit.Create(self);
Edit.Parent:=Self;
Edit.Left:=x;
Edit.Top:=y;
Edit.Height:=...
Edit.Width;=...
Edit.OnClick:=MyClick;
....
Edit.Show;end;狂人也有这样的例子,不过觉得简单,但是易用。。
用form的方法
findcomponent(名字)或 findchildcontrol(名字)
都可以(必须还要类型转换)
你在创建时把名字起好,
比如是edit就起“E”+字段名
label就起"l"+字段名
我试验过没问题
LOAD LABEL(1)
LABEL(1).LEFT=...
LABEL(1).TOP=...
LABEL(1).VISIBAL=TRUE
不需要使用的时候,只需UNLOAD LABEL(1)
注意只有在存在该控件的时候才能卸载,否则出错;
另外,如果不卸载而再加载一次,出错;
给分提供源码>
i : integer;
Lab : TLable;
Edt : TEdit;
begin
EditList := TList.Create;
LabList := TList.Create;
try
for i := 0 to FieldCount-1 do
begin
Lab := TLable.Create(self);
Edt := TEdit.Create(self);
Edt.Parent := form1 ;
Edt.Top := 100 ;
Edt.Left := 200 ; Lab.Parent := form1 ;
Lab.Top := 100 ;
Lab.Left := 100 ;
EditList.Add(Edt);
LabList.Add(Lab);
end; TEdit(EditList[0]).Text := 'Test';
finally
EditList := TList.Create;
LabList := TList.Create;
end;
end;
使用指针应该没有问题;我经常这样做.
procedure TForm1.Button1Click(Sender: TObject);
var
Btn: TButton;
begin
Btn := TButton.Create (self);
Btn.Parent := self;
Btn.Left :=20;
Btn.Top := 20;
Btn.Width := Btn.Width + 50;
Btn.Caption := Format ('Button at %d, %d', [10, 10]);
btn.OnClick:=buttonclick;end;procedure TForm1.ButtonClick(Sender: TObject);
beginshowmessage('笨蛋');
end;end.