Recent

Author Topic: How to change the properties of all components of the same class?  (Read 620 times)

Jvan

  • Full Member
  • ***
  • Posts: 181
For instance, I would like to change the text of every Edit.

Code: Pascal  [Select][+][-]
  1. AllEdits.Text := 'The same text';
« Last Edit: August 08, 2020, 11:58:42 pm by Jvan »

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: How to change the properties of all components of the same class?
« Reply #1 on: August 09, 2020, 12:07:02 am »
Yes, you can loop all controls owned by the form:
Code: Pascal  [Select][+][-]
  1.   for i:=0 to Form1.ControlCount-1 do
  2.     if Form1.Controls[i] is TEdit then
  3.       TEdit(Form1.Controls[i]).Text:='new text';
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Jvan

  • Full Member
  • ***
  • Posts: 181
Re: How to change the properties of all components of the same class?
« Reply #2 on: August 09, 2020, 12:21:39 am »
Yes, you can loop all controls owned by the form:
Code: Pascal  [Select][+][-]
  1.   for i:=0 to Form1.ControlCount-1 do
  2.     if Form1.Controls[i] is TEdit then
  3.       TEdit(Form1.Controls[i]).Text:='new text';

Thanks!

 

TinyPortal © 2005-2018