Einzelnen Beitrag anzeigen

Benutzerbild von Sharky
Sharky

Registriert seit: 29. Mai 2002
Ort: Frankfurt
8.251 Beiträge
 
Delphi 2006 Professional
 
#10

Re: Schleife für Label-Zuweisung

  Alt 29. Jun 2006, 07:33
Hai,

wenn eh ein Array da ist kann ich dort doch auch gleich die Werte und die Labels ablegen.
Delphi-Quellcode:
type
  TCounterRecord = record
    Counter: Integer;
    CounterLabel: TLabel;
  end;

var
  CounterArray: array[1..10] of TCounterRecord;

procedure TDemoForm.btn_testClick(Sender: TObject);
var
  ndx: Integer;
begin
  for ndx := Low(CounterArray) to High(CounterArray) do
  begin
    with CounterArray[ndx] do
    begin
      CounterLabel.Caption := IntToStr(CounterArray[ndx].Counter);
    end;
  end;
end;

procedure TDemoForm.FormCreate(Sender: TObject);
var
  ndx: Integer;
begin
  CounterArray[1].CounterLabel := Label1;
  CounterArray[2].CounterLabel := Label2;
  CounterArray[3].CounterLabel := Label3;
  CounterArray[4].CounterLabel := Label4;
  CounterArray[5].CounterLabel := Label5;
  CounterArray[6].CounterLabel := Label6;
  CounterArray[7].CounterLabel := Label7;
  CounterArray[8].CounterLabel := Label8;
  CounterArray[9].CounterLabel := Label9;
  CounterArray[10].CounterLabel := Label10;

  for ndx := 1 to 10 do
    CounterArray[ndx].Counter := ndx;
end;
Stephan B.
  Mit Zitat antworten Zitat