Author: Tomas Rutkauskas
I have a question about disabling containers. In my case I have a panel containing
a button. When disabling the panel the button is disabled, but not greyed. Why is
it not greyed?
Answer:
You have several options. Perhaps the easiest is to use this small routine which
iterates through a parent's children controls, enabling / disabling each in turn:
1 procedure EnableContainer(Parent: TWinControl; AEnabled: Boolean);
2 var3 I: Integer;
4 begin5 for I := 0 to Parent.ControlCount - 1 do6 Parent.Controls[I].Enabled := AEnabled;
7 Parent.Enabled := AEnabled;
8 end;
9 10 11 //So instead of doing this:12 13 14 Panel1.Enabled := False;
15 16 17 //do this instead:18 19 20 EnableContainer(Panel1, False);