Delphi遍历所有控件

方法一:(经测试,行得通)

var

  i:integer;
begin
  for i:= 0 to ComponentCount -1 do
  begin
    if (Components[i] is TEdit) and (TEdit(Components[i]).color = clred) then
      TEdit(Components[i]).Left:=TEdit(Components[i]).Left + 5;
  end;

end;

方法二:(技术有限,测试失败)

var
   c:TControl;
   i: integer ;
begin
   edit1 . Focused;
    for  i:= 0  to  self . ControlCount- 1  do
    begin
      c:=self . Controls[i];
      if  (c . ClassName= 'TEdit' and  ((c  as  TEdit).Focused)  then
        showmessage(c . Name);
 
    end ;
end ;

你可能感兴趣的:(Delphi遍历所有控件)