Arrays of DBEdit boxes lazarus / 10-Designer ---------------------------------------------------------------------- Penticom · 2017-02-28 05:31 OK, I am very used to changing the look and feel of Textboxes in an array. EG It is very handy for users to recognise if the back ground is white(edit) or Grey(viewonly) in our software. We have done this in the past be utilising arrays of texboxes or arrays of dbedit fields. EG EditField(0), EditField(1) etc etc etc. So how do I get the Lazarus TEdit or Dbedit boxes to be part of an array for better control ---------------------------------------------------------------------- molly · 2017-02-28 07:19 Instead of referencing those component from an array, why not place all those items you wish to 'modify' on a panel on its own ? You could then use something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,  StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Edit1: TEdit;  Edit2: TEdit;    Edit3: TEdit;    Edit4: TEdit;    Edit5: TEdit;    Memo1: TMemo;    Panel1: TPanel;    ToggleBox1: TToggleBox;    procedure ToggleBox1Click(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.ToggleBox1Click(Sender: TObject);var  i: integer;begin  for i := 0 to Pred(Panel1.ControlCount) do  begin    if (Sender as TToggleBox).Checked then    begin      case Panel1.Controls[i].ClassName of        'TEdit' : (Panel1.Controls[i] as TEdit).Color := clRed;        'TMemo' : (Panel1.Controls[i] as TMemo).Color := clYellow;      end;    end    else    begin      case Panel1.Controls[i].ClassName of        'TEdit' : (Panel1.Controls[i] as TEdit).Color := clBlue;        'TMemo' : (Panel1.Controls[i] as TMemo).Color := clGreen;      end;    end;  end;end; end.  Same technique can be used to 'store' the components into an array if you would still prefer that. ---------------------------------------------------------------------- howardpc · 2017-02-28 10:00 Forms already supply array properties containing all components and all controls. So you can adapt code such as the following (this example calls ColorAllEdits in the OnCreate, but in your program you would call it wherever appropriate). Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Forms, Controls, Graphics, StdCtrls, DbCtrls; type   TForm1 = class(TForm)    DBEdit1: TDBEdit;  DBEdit2: TDBEdit;    DBEdit3: TDBEdit;    Edit1: TEdit;    Edit2: TEdit;    Edit3: TEdit;    Edit4: TEdit;    procedure FormCreate(Sender: TObject);  private    procedure ColorAllEdits;  end;   TEditColors = array[boolean] of TColor; const  EditColors: TEditColors = (clWhite, clLtGray); // set your colors here var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.ColorAllEdits;var  c: TControl;  ed: TEdit absolute c;  dbe: TDBEdit absolute c;  i: Integer;begin  for i:=0 to ControlCount-1 do begin    c:=Controls[i];    if (c is TEdit) then      ed.Color:=EditColors[ed.ReadOnly]    else if (c is TDBEdit) then      dbe.Color:=EditColors[dbe.ReadOnly];  end;end; procedure TForm1.FormCreate(Sender: TObject);begin  ColorAllEdits;end; end. ---------------------------------------------------------------------- Penticom · 2017-03-01 13:27 OMG, all that code for 5 TEDit background color changes on a status change. Normaly did it in 5 lines of code. So Lazarus is going to be a BLOATED  coding then. GREAT!!! NOT! ---------------------------------------------------------------------- balazsszekely · 2017-03-01 13:45 QuoteOMG, all that code for 5 TEDit background color changes on a status change. Normaly did it in 5 lines of code. So Lazarus is going to be a BLOATED  coding then. GREAT!!! NOT!Think again! What if you have 100 TEdits instead of five? Then your code is gonna be the bloated one. Both @molly and @howardpc gave you a generic solution and yes for five TEdit perhaps it's not worth the effort, but then what was your question about?