Mega Code Archive

 
Categories / Delphi / VCL
 

Greying out the Controls on a groupbox

Title: Greying out the Controls on a groupbox Question: If you disable a group box, none of the controls work but they all look as if they will. This is confusing. The controls in the box should look greyed out. Answer: A very short procedure which just goes through the controls in the Groupbox and sets the enabled state of each to that of the Box itself. procedure GreyOutGB(GroupBox : TGroupBox); var IsEnabled : boolean; Index : integer; begin Isenabled := GroupBox.Enabled; for Index := 0 to Groupbox.Controlcount-1 do GroupBox.controls[Index].Enabled := Isenabled; end; Call this after enabling/disabling the groupbox. Unfortunately the title of the Groupbox isn't itself greyed out (Anyone know how without rewriting the VCL?), but it looks much more effective.