Autor Beitrag
pbin.michael
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Do 17.03.05 09:08 
Hi,

hab ein kleineres Problem glaub ich.

Und zwar hab ich 5 Edit.Felder in dem Daten eingegebn werden. Per buttonclick werden die Daten dann in eine Listbox eingefügt. Ich möchte nun, wenn ich auf ein Feld in der Listbox klicke, dass die Daten wieder geteilt werden und in die einzelnen 5 Edit.Felder übetragen werden, sodass ich die Daten z.B. ändern kann.

Wie stelle ich das an? = )

Danke schon einmal im vorraus
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 17.03.05 09:12 
:welcome:
und viel Spaß im Forum.

Ohne jetzt Delphi zur Hand zu nehmen:
Die Komponente TListBox hat die Eingeschaft Items. Dort kannst du über den Index auf jedes ListBox-Item zugreifen. Achtung: Der Index fängt bei 0 an.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
  Edit1.Text := Listbox1.Items[0];
  Edit2.Text := Listbox1.Items[1];  
  Edit3.Text := Listbox1.Items[2];  
  Edit4.Text := Listbox1.Items[3];
  Edit5.Text := Listbox1.Items[4];

Das ganze ließe sich auch mit einer Schleife machen. Dafür benötigst du noch FindComponent. Nimm einfach mal die Suchfunktion im Forum.
pbin.michael Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Do 17.03.05 09:16 
warte warte...ich hab mich vielleicht falsch ausgedrückt ;)

ausblenden Delphi-Quelltext
1:
ListBox1.Items.Add(Edit1.Text +';'+ Edit2.Text +';'+ Edit3.Text +';'+ Edit4.Text +';'+ Edit5.Text + ';');					


ich habe alle edit.felder in EINEM item . und darum geht es mir. das item aufzusplitten in die 5 edit.felder
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 17.03.05 09:25 
Kein Problem.
Du benötigst Pos, Copy, Delete. Alles String-Funktionen.
Ich könnte dir jetzt Source dazu schreiben, mache ich aber nicht. :wink:
Auf meiner Homepage findest du unter Tutorials einen Bereich mit Stringverarbeitung. Dort sind alle wichtigen String-Funktionen und -Prozeduren drin. Gibt sogar Demo-Source und Demo-Programm.

Sollte es ein dringendes Problem sein, dass du JETZT lösen musst, dann poste nochmal. Der Lerneffekt ist dann aber nicht so gut.
pbin.michael Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Do 17.03.05 09:44 
hehe, das mit pos und copy wusste ich bereits schon, jedoch kam ich nicht ganz klar damit, aber ich werde es mir mal auf deiner homepage anschauen. danke
pbin.michael Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Do 17.03.05 10:11 
...ich bin genauso weit wie vor 1-2 wochen = )

...ich gehör zu denen die sich functionen x.mal anschauen können aber nix kapieren , bzw. was damit anzufangen.

...zur info...ich bin noch azubi fachinformatiker mit schwerpunkt anwendungsentwicklung und hab in meinem leben noch kein meter programmiert... = )
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 17.03.05 10:21 
ungetestet kannst du etwa so anfangen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var s: String;
p: Byte;
begin
  s := ListBox1.Items[ListBox1.ItemIndex];
  p := pos(';',s);  // Trennzeichen finden
  Edit1.Text := Copy(s,1,p-1);  // Teil vor dem Trennzeichen ins erste Edit
  s := Copy(s,p+1,255); // Rest hinter dem Trennzeichen kopieren, um beim nächsten Aufruf von Pos das nächste Semikolon zu finden
end;
pbin.michael Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Do 17.03.05 10:33 
danke! = )
pbin.michael Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 20



BeitragVerfasst: Do 17.03.05 11:01 
gut gut ! = )

jetzt hab hab ich also den itemindex wieder in den edit.feldern drin

wie ändere ich nun durch veränderte eingabe der editfelder wieder den itemindex ohne ein neues item hinzuzufügen?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 17.03.05 13:07 
Ohne zu testen:
ausblenden Delphi-Quelltext
1:
listbox1.items[die_korrekte_nummer] := Edit1.Text+';'+Edit2.Text+.....