Autor Beitrag
Bountyhunter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Sa 04.10.03 18:28 
hallo!
ich hab ne listbox mit mehreren items. nun will ich, dass wenn das item "hallo" angeklickt wird, ein wert in einem edit feld erscheint und wenn man das item "servus" anklickt ein anderer wert. das bekomm ich aber net hin. ich hab mal ein bisschen was gemacht:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
begin
if listbox1.item.text='hallo' then x:=5;              //diese zeile funzt nicht
if listbox1.item.text='servus' then x:=10;
Edit2.Text := IntToStr(x*StrToInt(Edit1.Text)); //diese zeile funzt

stimmt hier was nicht? wie würdet ihr das machen?
mfg
Bountyhunter

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt; Topic verschoben.
Keldorn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 2266
Erhaltene Danke: 4

Vista
D6 Prof, D 2005 Pro, D2007 Pro, DelphiXE2 Pro
BeitragVerfasst: Sa 04.10.03 19:01 
Hallo

Zitat:

//diese zeile funzt nicht

immer diese präzisen Fehlerangaben :roll:

Aber ein wenig in der hilfe rumstöbern hätte Dir nicht geschadet, da dir die Fehlermeldung sicher sagt, daß irgendwas nicht feiniert ist. items ist ein TStrings und da sieht der Zugriff anders aus

ausblenden Delphi-Quelltext
1:
2:
3:
4:
  if listbox1.itemindex<>-1 then  //ist wirklich ein item ausgewählt (sonst gibts ne Exception 
    begin
      if listbox1.items[listbox1.itemindex]='hallo' then x:=5; 
   ...

achte noch darauf, das listbox1.items[listbox1.itemindex]='hallo' die groß und kleinschreibung berücksichtigt, also wenn "Hallo" drin steht, gehts nich (gugg dir ansiuppercase/ansilowercase an)

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
Bountyhunter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19



BeitragVerfasst: Sa 04.10.03 20:36 
Danke, fetzt funzt es :lol:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if listbox1.itemindex<>-1 then  //ist wirklich ein item ausgewählt (sonst gibts ne Exception) 
    begin 
      if ListBox1.Items[ListBox1.ItemIndex]='Hallo' then x:=5;
      if ListBox1.Items[ListBox1.ItemIndex]='Servus' then x:=10;
Edit2.Text := IntToStr(x*StrToInt(Edit1.Text)); //diese zeile funzt

so hab ichs dann im endeffekt im quellcode stehn.
mfg
Bountyhunter

Moderiert von user profile iconTino: Delphi-Tags hinzugefügt.