Thema: Delphi Labels in ein Array?

Einzelnen Beitrag anzeigen

Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#10

Re: Labels in ein Array?

  Alt 29. Jan 2004, 13:37
So irgendwie:
Delphi-Quellcode:
type
  TForm1 = class(TForm)
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.Button1Click(Sender: TObject);
var
  Loop: Cardinal;
begin
  for Loop := 1 to 3 do
  begin
    with TCheckBox(FindComponent('Checkbox'+IntToStr(Loop))) do
    begin
      if Checked then
        TLabel(FindComponent('Label'+IntTostr(Loop))).Visible := True
      else
        TLabel(FindComponent('Label'+IntTostr(Loop))).Visible := False;
    end;
  end;
end;
Aber ich bekomme immer in den TLabel-Zeilen ein AV.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat