SetLength(vMenuItemList,vCount); for i:=0 to ComponentCount -1 do begin if (Components[i].ClassName='TMenuItem') then begin if Components[i].Tag<-1 then Continue; vMenuItemList[j]:=TMenuItem(Components[i]); Inc(j); end; end;这是我建立菜单数组的例子,你看看是否合用? 在FormShow事件里写的,vMenuItemList就是菜单数组。vCount是我计算好的数量。
没必要数组了,把这些edit放到一个groupbox或者panel等容器控件里面,然后调用 (groupbox.component[i] as Tedit).xxx就可以了
查找var tmpEdit:TEdit; for i:=3 to 10 do begin tmpEdit:=self.FindComponent('edit'+inttost(i)); if tmpEdit<>nil then MEdit[i]:=tmpEdit; end;
var i: Integer; begin for i := 3 to 10 do MEdit[i] := TEdit(findComponent('edit' + IntToStr(i))); end;
但我要在别外自己做的模块里对这8个Edit赋值呀?
c:=3; for i:=0 to self.controlCount-1 do begin if self.controls[i] is tedit then begin medit[c]:=self.controls[i]; inc(c); end; end;
for i:=0 to ComponentCount -1 do
begin
if (Components[i].ClassName='TMenuItem') then
begin
if Components[i].Tag<-1 then Continue;
vMenuItemList[j]:=TMenuItem(Components[i]);
Inc(j);
end;
end;这是我建立菜单数组的例子,你看看是否合用?
在FormShow事件里写的,vMenuItemList就是菜单数组。vCount是我计算好的数量。
(groupbox.component[i] as Tedit).xxx就可以了
tmpEdit:TEdit;
for i:=3 to 10 do
begin
tmpEdit:=self.FindComponent('edit'+inttost(i));
if tmpEdit<>nil then MEdit[i]:=tmpEdit;
end;
i: Integer;
begin
for i := 3 to 10 do
MEdit[i] := TEdit(findComponent('edit' + IntToStr(i)));
end;
for i:=0 to self.controlCount-1 do
begin
if self.controls[i] is tedit then
begin
medit[c]:=self.controls[i];
inc(c);
end;
end;