Solved

Tpanel color

Posted on 2004-08-02
1
1,049 Views
Last Modified: 2008-01-09
How can i loop through all tpanels on a form to change the color?
0
Comment
Question by:KLOPEKS
1 Comment
 
LVL 12

Accepted Solution

by:
esoftbg earned 85 total points
ID: 11691397
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Buttons, StdCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    Edit1: TEdit;
    ListBox1: TListBox;
    SpeedButton1: TSpeedButton;
    procedure SpeedButton1Click(Sender: TObject);
  private   { Private declarations }
  public    { Public declarations }
    procedure ChangePanelsColor(Cl: TColor);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ChangePanelsColor(Cl: TColor);
var
  I:      Integer;
begin
  for I := 0 to ComponentCount-1 do
    if (Components[I].ClassType=TPanel) then
      (Components[I] as TPanel).Color := Cl;
end;

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  ChangePanelsColor(clSkyBlue);
end;

end.

emil
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question