Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
Changing properties for all components of a certain type Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
13-Sep-02
Category
VCL-General
Language
Delphi All Versions
Views
69
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert

Changing properties for all components of a certain type

Answer:

To change the font color of all the labels of a form to a certain color, call the 
following procedure. In the call itself, you have to replace NewColor with an 
existing color, e.g. SetLabelsFontColor(clRed) sets all the labels' font color to 
red.

1   procedure TForm1.SetLabelsFontColor(NewColor: TColor);
2   var
3     i: Integer;
4   begin
5     for i := 0 to ComponentCount - 1 do
6       if Components[i] is TLabel then
7         TLabel(Components[i]).Font.Color := NewColor;
8   end;
9   
10  of course, you can use this technique to change other properties of other 
11  components. to change the color of all edits, the code would be: 
12  
13  procedure TForm1.SetEditsColor(NewColor: TColor);
14  var
15    i: Integer;
16  begin
17    for i := 0 to ComponentCount - 1 do
18      if Components[i] is TEdit then
19        TEdit(Components[i]).Color := NewColor;
20  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC