仅供参考:
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to ControlCount-1 do
if Controls[i] is TLabel then
Showmessage(Controls[i].Name);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to ControlCount-1 do
if Controls[i] is TLabel then
Showmessage(Controls[i].Name);
end;
解决方案 »
- 希望用REGSVR32.EXE注册dll
- 关于读取word的问题
- 请教,如何用代码让控件在有数据改变时不显示,批量修改完再显示?因为数据量大的时候花屏闪烁
- 请问DDOS等洪水攻击软件是如何制作的
- QuickReport的打印问题,急!
- 求助!nasm编译出来的bin文件怎么用?
- MDIChild类型的子窗口,大家打开的时候是放中间还是放左上角?
- 紧急求救——Rava Report选择打印页的问题!!!!
- 哪位有关于delphi自带安装程序制作工具Install Shield Profession的帮助文件啊.小弟有急用谢谢了
- label动态显示问题
- 一个极简单的问题,如何去掉DELPHI5的菜单的默认快捷键?送20分!!
- Delphi的好汉,请留下0icq!
TIniFile ini;
ini=new TIniFile(ChangeFileExt(Application->ExeName,".INI"));
for(i=0;i<count;i++)
ini->WriteInterger("Form","Caption",mylabel[i]->Caption);
1.控件数组:var
Form1: TForm1;
Button: array[0..2] of TButton;implementationuses hit,DdnSizerControl;{$R *.DFM}
procedure TForm1.ButtonMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if ssCtrl in Shift then
begin
ReleaseCapture;
(Sender as TWinControl).Perform(WM_SysCommand, sc_DragMove, 0);
end
else
frmHit.Show;
end;procedure TForm1.FormCreate(Sender: TObject);
var
iCount: Integer;
begin
for iCount := 0 to 2 do
begin
Button[iCount] := TButton.Create(Self);
Button[iCount].Caption := 'Button' + IntToStr(iCount);
Button[iCount].Parent := Self;
Button[iCount].Left := iCount * 10;
Button[iCount].Top := iCount * 30;
Button[iCount].OnMouseDown := ButtonMouseDown;
end;end;2.FindComponent()方法获取控件
如:
TLabel(FindComponent('Label1').Caption := 'Find Label';
帮助中的例子:
procedure TForm1.Button1Click(Sender: TObject);var
i: Integer;
const
NamePrefix = 'MyEdit';
begin
for i := 1 to 20 do begin
TEdit.Create(Self).Name := NamePrefix + IntToStr(i);
with TEdit(FindComponent(NamePrefix + IntToStr(i))) do
begin
Left := 10;
Top := i * 20;
Parent := self;
end;
end;
end;
用tag 属性比较灵活你只许判断tag 的值
begin
if Components[i] is TLabel then
if TLabel(components[i]).name='....' then
TLabel(components[i]).caption:='......'
end;
list:TList;
procedure xx;
var
tlbl:TLabel;
begin
if list<>nil then
list.free;
list:=Tlist.Create;
while not table1.eof do
begin
tlbl:=TLabel.Create(self);
tlbl.caption:=XXExchangetostr(table1.fieldbyName('xx'));
list.additem(tlbl);
table1.next;
tlbl.free;
end;
end;
在程序退出时别忘了释放list 哦!
我现在心情不好(我在和情敌竞争)http://www.csdn.net/expert/topic/108/108760.shtm来给我出个主义吧!
可以这样实现:
procedure TForm1.Button1Click(Sender: TObject);
begin
Table1.First;
While not Table1.Eof do
begin
TLabel(FindCompoent(Tabel1.FieldbyName('LabelName'))).Caption := 'New Caption';
Table1.Next;
end;
end;