var t,l,i:integer; begin t:=25; l:=30; for I := 0 to Self.ComponentCount - 1 do if Self.Components[i] is TEdit then begin TEdit(Self.Components[I]).top:=t; TEdit(Self.Components[I]).left:=l; t:=t+30; end; end;
楼上的方法对隐藏的edit会遍历吗? 因为隐藏了几个所以要重新排列
var t,l,i:integer; begin t:=25; l:=30; for I := 0 to ComponentCount - 1 do if Components[i] is TEdit then begin if TEdit(Components[i]).Visible then begin TEdit(Components[I]).top:=t; TEdit(Components[I]).left:=l; t:=t+30; end; end; end;
也就是怎么找出没有隐藏的edit然后设置他的left和top
t,l,i:integer;
begin
t:=25;
l:=30;
for I := 0 to Self.ComponentCount - 1 do
if Self.Components[i] is TEdit then
begin
TEdit(Self.Components[I]).top:=t;
TEdit(Self.Components[I]).left:=l;
t:=t+30;
end;
end;
因为隐藏了几个所以要重新排列
t,l,i:integer;
begin
t:=25;
l:=30;
for I := 0 to ComponentCount - 1 do
if Components[i] is TEdit then
begin
if TEdit(Components[i]).Visible then
begin
TEdit(Components[I]).top:=t;
TEdit(Components[I]).left:=l;
t:=t+30;
end;
end;
end;