How to color TPanels on a form according to their Tag properties (Views: 27)
Problem/Question/Abstract: How to color TPanels on a form according to their Tag properties Answer: { ... } var ix: Integer; pnl: TPanel; { ... } for ix := 0 to ComponentCount - 1 do begin if Components[ix] is TPanel then begin pnl := TPanel(Components[ix]); case pnl.Tag of 1: pnl.Color := clRed; 2: pnl.Color := clBlue; else pnl.Color := clBtnFace; end; end; end; Try placing the above code in a button OnClick event handler (having dropped some TPanels on the form with different Tag values). |