AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

ListBox & Edit

Ein Thema von CorsaGsi16v · begonnen am 6. Sep 2006 · letzter Beitrag vom 6. Sep 2006
Antwort Antwort
CorsaGsi16v

Registriert seit: 23. Feb 2006
16 Beiträge
 
#1

ListBox & Edit

  Alt 6. Sep 2006, 16:25
Hallo,
habe in einer ListBox einige Strings. Beim Anklicken eines Strings soll dieser zerteilt werden und auf die memos aufgeteilt werden. So z.B.

1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9

Jetzt soll das Item in 9Edits aufgeteilt werden wobei die Zahlen hier im Programm durch Wörter ersetzt sind und nicht immer gleich lang sind!

Also das soll dann im Endeffekt herauskommen:

Edit1.Text := '1';
Edit2.Text := '2';
...
Edit9.Text := '9';

Ich habe schon einige Sachen ausprobiert komme aber nicht drauf wie ich das umsetzen muss!

Kann mir jemand behilflich sein?

MfG
Christian

Danke schon mal für die Hilfe...
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#2

Re: ListBox & Edit

  Alt 6. Sep 2006, 16:38
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender:TObject);
var i: Integer;
begin
 for i:= 0 to ListBox1.Items.Count-1 do
 begin
   (FindComponent('Edit' + IntToStr(i+1) as TEdit).Text := ListBox1.Items[i];
 end;
end;
So müsste es gehn. Vorraussetzung: Es muss so viele Edits geben wie es Einträge in der ListBox gibt!

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
CorsaGsi16v

Registriert seit: 23. Feb 2006
16 Beiträge
 
#3

Re: ListBox & Edit

  Alt 6. Sep 2006, 17:21
danke.. aber nicht falsch verstehen ich will wenn ich auf irgendein item in der ListBox klicke das den inhalt...

1 _ 2 _ 3 _ 4 _ 5 _ 6 _ 7 _ 8 _ 9

hat, den inhalt dieser einen Zeile auf die 9 vorhandenen Edits aufteilen!


MfG
Christian
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#4

Re: ListBox & Edit

  Alt 6. Sep 2006, 17:28
Ach so.. ups
Moment muss mal überlegen

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#5

Re: ListBox & Edit

  Alt 6. Sep 2006, 17:39
Delphi-Quellcode:
procedure TForm1.ListBox1Click(Sender: TObject);
var i: Integer;
    tmp: String;
begin
  i:= 1;
  tmp := ListBox1.Items[ListBox1.ItemIndex] + '_';
  repeat
    if FindComponent('Edit' + IntToStr(i) = nil then exit;
    (FindComponent('Edit' + IntToStr(i)) as TEdit).Text := copy(tmp,1,pos('_',tmp)-1);
    delete(tmp,1,pos('_',tmp));
    inc(i);
  until Length(tmp) = 0;
end;
Ich habe fertig

Gruß
Neutral General
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat
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
CorsaGsi16v

Registriert seit: 23. Feb 2006
16 Beiträge
 
#7

Re: ListBox & Edit

  Alt 6. Sep 2006, 19:13
Ihr seid die besten DANKE!!!
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:57 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz