Thema: Delphi ListBox & Edit

Einzelnen Beitrag anzeigen

hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.270 Beiträge
 
Delphi 10.4 Sydney
 
#6

Re: ListBox & Edit

  Alt 6. Sep 2006, 17:40
Hallo,

in ListBox.Items[ListBox.ItemIndex]; steht der String.

Ich würde ne TStringList benutzen mit Delemiter und DelimitedText

also
Delphi-Quellcode:
var
  SL: TStringList;
  iWord: Integer;
  Edit: TEdit;
  iEdit: Integer;
begin
  for iEdit:= 1 to 9 do
  begin
    Edit:= FindComponent('Edit'+IntToStr(iEdit));
    if Edit<>NIL then Edit.Text:= '';
  end;

  SL:= TStringList.Create;
  try
    SL.Delimiter:= ' '; // Leerzeichen
    SL.DelimitedText:= ListBox.Items[ListBox.ItemIndex];

    for iWord:= 0 to SL.Count-1 do
    begin
      if iWord>8 then break; // bis 9 hattest du gesagt ?
                             // wir beginnen bei 0 ...

      Edit:= FindComponent('Edit'+IntToStr(iWord+1));
      if Edit<>NIL then
      begin
        Edit.Text:= SL[iWord];
      end;
    end;
  finally
    SL.Free;
  end;
end;
Heiko
Heiko
  Mit Zitat antworten Zitat