【发布时间】:2010-09-29 17:15:41
【问题描述】:
我有一个带有一堆控件的表单,我想遍历某个面板上的所有控件并启用/禁用它们。
我试过了:
var component: TComponent;
begin
for component in myPanel do
(component as TControl).Enabled := Value;
end;
但这并没有起到任何作用。原来所有组件都在表单的组件集合中,而不是它们的父对象。那么有谁知道是否有任何方法可以将所有控件放入控件中? (除了像这样丑陋的解决方法,这是我最终不得不做的):
var component: TComponent;
begin
for component in myPanel do
if (component is TControl) and (TControl(component).parent = myPanel) then
TControl(component).Enabled := Value;
end;
请告诉我有更好的方法...
【问题讨论】:
标签: delphi forms controls iterator vcl