Autor Beitrag
JeanvanHees
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Fr 23.08.02 11:00 
Gutenmorgen Auq.de...
Wie bekomme ich die index von ein selected item in eine listbox?
Ich habe 'listbox.itemindex' schon probiert aber das war scheinbar nur zum einführen von strings in die listbox?
Es funktionierte jedenfals nicht.

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!


Zuletzt bearbeitet von JeanvanHees am Fr 23.08.02 11:05, insgesamt 1-mal bearbeitet
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Fr 23.08.02 11:03 
Hallo,

mit der Eigenschaft die Du genannt hast (ItemIndex) bekommt man den Index des selektierten Eintrags. Versuch es mal einfach noch mal!

Gruß
TINO
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Fr 23.08.02 11:09 
Diese procedure returniert mir mit listbox1.itemindex immer nur 0. Also ist auch die if immer true.
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm3.Button2Click(Sender: TObject);
begin
  If not listbox1.ItemIndex = -1 then
    select:=listbox1.ItemIndex;
  Memo1.Lines.add(inttostr(select));
  Eptoshow:= listbox1.Items.Names[select];
  unit5.Form5.Show;
  Memo1.Lines.Add(Eptoshow);
end;

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
Teutobod
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 55



BeitragVerfasst: Fr 23.08.02 11:25 
Zitat:
If not listbox1.ItemIndex = -1


Ein bisschen Kompliziert, hm?
Hab ich das richtig verstanden, du willst die selektierte Zeile ins Memofeld schreiben?
Funktioniert eigentlich eh (fast) mit deinem Code. Solltest vielleicht nur noch nach dem if...then ein begin und zum Schluß ein end; einfügen.
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Fr 23.08.02 11:37 
Indertat ist ein begin und end nötig.
Aber jetzt macht er gar nichts; also bekomm ich immer ein -1 zurück.
Was ich hier falsch mache wird sicher etwas ganz blödes sein denke ich. :(

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
Teutobod
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 55



BeitragVerfasst: Fr 23.08.02 11:42 
Probier doch einfach mal das aus
ausblenden Quelltext
1:
If listbox1.ItemIndex >= 0					


ist irgendwie nicht so umständlich
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Fr 23.08.02 11:46 
Ich hab es auf deine weise gemacht und jetzt tut das ding es. :x
Naja, danke für deine hilfe. :)

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!
SMI
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 106

Win95-2003 / Debian / Suse
D1/D3/D6/D7
BeitragVerfasst: Fr 23.08.02 11:51 
Man könnte auch if listbox1.selcount >0 Then .... nutzen

SMI
JeanvanHees Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 146

win 2000
D6 Pers
BeitragVerfasst: Fr 23.08.02 12:37 
Ja, Ich denke das ich mal was weiniger in mixed-logic denken muss.
:wink:

_________________
Cause even though I know things won't get any better, they can certainly never get much worse!