Solved

TComponent(TLabel change font size)

Posted on 2004-04-27
3
579 Views
Last Modified: 2013-12-03
Hi

I want to change all my Tlabel's font size to 9. How can I do that instead of going to each labels and change its property field. Each label have different names.. so I can use the FindComponent

ex.
var
  i: Integer;
begin
  for i := 1 to 20 do begin
    with TLabel(FindComponent(Label + IntToStr(i))) do
      Font := 9;
  end;

Many thanks and cheers,
mha
0
Comment
Question by:michaenh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 125 total points
ID: 10927554
Hi,

 Try this:

var i: integer;
begin
  for i := 0 to Form1.ComponentCount - 1 do begin
    if (Form1.Components[i] is TLabel) then
      (Form1.Components[i] as TLabel).Font.Size := 15;
  end;
end;

Regards, Geo
0
 

Author Comment

by:michaenh
ID: 10927654
Thanx.

You are the greatest!
:) cheers

mha
0
 
LVL 17

Expert Comment

by:geobul
ID: 10927867
The pleasure was mine :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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