//包含控件数: var num: Integer; begin num := Self.ControlCount; ShowMessage('窗体上共有控件: ' + IntToStr(num)); //没有包括不可视控件和panl内的控件 //ShowMessage('Panel1上共有控件: ' + IntToStr(Panel1.ControlCount)); end;
//遍历窗体上的控件: var i: Integer; begin for i := 0 to Self.ControlCount - 1 do begin ShowMessage(Self.Controls[i].Name); end; end;