How to change Object proprierties in a FOR cycle lazarus / 13-General ---------------------------------------------------------------------- ciammaruca · 2014-11-03 07:12 hi, how to change properties of several Objects in a cycle FOR? In my example i'd like to change to Enabled:=FALSE all my seven LabeledEdit. Like this approximately:    for i:=1 to 7 do    begin    ('LabeledEdit+i').Enabled:=False;    end; ---------------------------------------------------------------------- hy · 2014-11-03 07:40 Code: [Select]var       i     :  integer;    begin       for i := 0 to self.ComponentCount do       begin          if self.Components[i] is TLabeledEdit then             TLabeledEdit(Components[i]).enabled := false;       end;    end;     ---------------------------------------------------------------------- ciammaruca · 2014-11-03 14:12 ok, thanks; neverthless: if i put only one line it's all ok; but when i put more then one line it's a caos! The first line is not executed, the second one is applied to all objects! So, my TLabeledEdit are with a checkbox inside a groupbox, in a Form2. For example, when i put these lines, also checkbox is made disabled:        TLabeledEdit(Components).Font.Size:=6;        TLabeledEdit(Components).enabled := false; On the contrary when i put  these lines, also checkbox and groupbox captions are made  Font.Size:=6:        TLabeledEdit(Components).enabled := false;        TLabeledEdit(Components).Font.Size:=6; And so on with the different proprierties. ---------------------------------------------------------------------- marcov · 2014-11-03 16:04 Your code has   TLabeledEdit(components).xxx, while hy's code has Code: [Select]TLabeledEdit(components[i]).xxx ---------------------------------------------------------------------- Blaazen · 2014-11-03 16:24 QuoteYour code has   TLabeledEdit(components).xxx, while hy's code has ...I guess he has it too but forum software changed [ i ] to italic font because he didn't use the [ code ] tag for code. ---------------------------------------------------------------------- Bart · 2014-11-03 16:26 Quote from: ciammaruca on November 03, 2014, 03:12:26 pmok, thanks; neverthless: if i put only one line it's all ok; but when i put more then one line it's a caos! The first line is not executed, the second one is applied to all objects! So, my TLabeledEdit are with a checkbox inside a groupbox, in a Form2. For example, when i put these lines, also checkbox is made disabled: Code: [Select]       TLabeledEdit(Components[i]).Font.Size:=6;        TLabeledEdit(Components[i]).enabled := false; On the contrary when i put  these lines, also checkbox and groupbox captions are made  Font.Size:=6: Code: [Select]       TLabeledEdit(Components[i]).enabled := false;        TLabeledEdit(Components[i]).Font.Size:=6; A guess you forgot to put these into a begin / end block. Try: Code: [Select]var    i     :  integer; begin    for i := 0 to self.ComponentCount do    begin       if self.Components[i] is TLabeledEdit then       begin //if you don't use the begin/end then the second statement will always be executed!          TLabeledEdit(Components[i]).enabled := false;          TLabeledEdit(Components[i]).Font.Size:=6;       end;    end; end; Bart ---------------------------------------------------------------------- ciammaruca · 2014-11-03 18:29 hi,  yes, you right! I forgot the begin/end. Cadena perpetua para mi. saluti