var
i: integer;
begin
for I := 1 to ComponentCount do
TButton(FindComponent('Button'+IntToStr(I))).Caption:=IntToStr(I);
end;
这样编历是有些浪费,但是我觉得别无选择。
i: integer;
begin
for I := 1 to ComponentCount do
TButton(FindComponent('Button'+IntToStr(I))).Caption:=IntToStr(I);
end;
这样编历是有些浪费,但是我觉得别无选择。
begin
if Components[i] is TLabel then begin
s := (Components[i] as TLabel).Name;
//.....
end;end;
TLabel(FindComponent(Format('Label%d' ,[I]))).Caption := '有什么不好?';//设计期对Index次序的调整
//就是对层次的调整
FindComponent对一般的程序是没问题了,但对数控类时间精度较高的程序在使用元件很多时不理想。最好是不用查询,能直接引用Index。//设计期对Index次序的调整
//就是对层次的调整这句是不是说Bring to front or Send to back有效?
ShowMessage(IntToStr(Button1.ComponentIndex));
ShowMessage(IntToStr(Button2.ComponentIndex));除了Bring ... ... 还可以直接修改窗体代码object Button1: TButton1
Caption = 'Button1'
//... ...
end
object Button2: TButton2
Caption = 'Button2'
//... ...
end------------------>>>>>>>>>>>>object Button2: TButton2
Caption = 'Button2'
//... ...
end
object Button1: TButton1
Caption = 'Button1'
//... ...
end