T
TC_2006
Unregistered / Unconfirmed
GUEST, unregistred user!
我有一个function用来清除面板(panel)上的控件的Text,如下:
procedure TfrmMain.ResetForm(PanelObject : TPanel);
var
i : integer;
begin
for i := 0 to PanelObject.ComponentCount - 1 do
begin
if PanelObject.Controls is TEdit then
begin
(PanelObject.Controls as TEdit).clear;
(PanelObject.Controls as TEdit).Enabled := True;
(PanelObject.Controls as TEdit).Color := clwindow;
end;
end;
end;
然后我在一个Button的单击事件上调用它
ResetForm(panel1);
可是走到PanelObject.ComponentCount 的时候,componentCount竟然为0,为什么呢??
procedure TfrmMain.ResetForm(PanelObject : TPanel);
var
i : integer;
begin
for i := 0 to PanelObject.ComponentCount - 1 do
begin
if PanelObject.Controls is TEdit then
begin
(PanelObject.Controls as TEdit).clear;
(PanelObject.Controls as TEdit).Enabled := True;
(PanelObject.Controls as TEdit).Color := clwindow;
end;
end;
end;
然后我在一个Button的单击事件上调用它
ResetForm(panel1);
可是走到PanelObject.ComponentCount 的时候,componentCount竟然为0,为什么呢??