Board index » delphi » Assigning Objects same property

Assigning Objects same property

Is it possible on creation of my form to say for instance assign all Tedit
object the same color by using a Type statement.  I am aware of (sender is
Tedit) and (Source as Tedit) however I would like to be able to assign all
the same objects the same color.  Is there as easier way of doing this
instead of individually assigning every object the color property?

--

Marko
---------------
m...@sepcoinc.com

 

Re:Assigning Objects same property


Marko, try this:
var
  t : integer;
begin
  for i := 0 to Form1.ComponentCount-1 do
    if Form1.Components[t] is TPanel then
      TPanel(Form1.Components[t]).Color := clRed;
end;

(I got this answer from a message that had been  posted earlier.)

Carrie

Re:Assigning Objects same property


You can use a for loop to iterate through all components on your form and
test them for TEdit and then change the color property.

var
  i: Integer;
begin
  for i := 0 to ComponentCount -1 do
    if Components[i] is TEdit then
      TEdit(Components[i]).Color := clBlue;
end;

Marko <ma...@mtco.com> skrev i artiklen
<yL_Z1.119$Y%4.1272...@iagnews.iagnet.net>...

Quote
> Is it possible on creation of my form to say for instance assign all
Tedit
> object the same color by using a Type statement.  I am aware of (sender
is
> Tedit) and (Source as Tedit) however I would like to be able to assign
all
> the same objects the same color.  Is there as easier way of doing this
> instead of individually assigning every object the color property?

Re:Assigning Objects same property


Thanx for all your help

--

Marko
---------------
m...@sepcoinc.com

Quote
Marko wrote in message ...

Other Threads