Autor Beitrag
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mo 21.02.05 21:29 
Hallo, ich möchte bei einer ListBox abfragen welches Item markiert ist, und zwar nicht den Namen des Item welches ich anklicke, sondern die Nummer der Schaltfläche: Ob ews die erste die Zweite oder dritte usw. ist.
Wie stelle ich das an?
Invulnerabilis
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: Mo 21.02.05 21:31 
listbox.itemindex oder bei multiselect über die Eigenschaft
listbox1.selected[Schleifenzähler]=true gehen

Mfg Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)
PattyPur
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 80

Win98, WinXP
Delphi 7
BeitragVerfasst: Mo 21.02.05 21:33 
das Stichwort lautet ItemIndex :-)
Schau mal in die Hilfe


/edit: Mist da war einer Schneller ;-)
der_zaehe
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 317

WinXP SP2
D6 Pers, D2005 Prof, VS2005
BeitragVerfasst: Mo 21.02.05 21:39 
lies da mal die unteren einträge

_________________
[inspirationslos]
Christian V. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mo 21.02.05 22:07 
Also das mit ItemsIndex kapier ich nicht, und listbox1.selected gibts erst gar nicht. Kann mir jemand nicht einen Codeschnipsel geben, wo am schluss rauskommt ob ich das erste oder zweite usw angeclickt habe?
Invulnerabilis
PattyPur
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 80

Win98, WinXP
Delphi 7
BeitragVerfasst: Mo 21.02.05 23:00 
Delphi-Hilfe:
Die Eigenschaft ItemIndex gibt den Index des im Listenfeld ausgewählten Eintrags an.

Delphi-Syntax:

property ItemIndex: Integer;

C++ Syntax:

__property int ItemIndex = {read=GetItemIndex, write=SetItemIndex, nodefault};

Beschreibung

Mit ItemIndex können Sie zur Laufzeit einen Eintrag auswählen. Setzen Sie dazu den Wert
von ItemIndex auf den Index des auszuwählenden Eintrags. Der Index des ersten Eintrags ist
0. Wenn kein Eintrag ausgewählt ist, hat ItemIndex den Wert -1 (dies ist zugleich der
Vorgabewert, wenn MultiSelect false ist).

Hat die Eigenschaft MultiSelect den Wert true, können mehrere Einträge des Listenfeldes
ausgewählt werden. In diesem Fall ist ItemIndex der Index des Eintrags, der den Fokus hat.
Wenn MultiSelect true ist, ist der Vorgabewert für ItemIndex 0.


Also ich versteh jetzt nicht was daran unverständlich sein soll.

Moderiert von user profile iconTino: Code- durch Quote-Tags ersetzt.
Christian V. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mo 21.02.05 23:10 
ich meine wie ich das als Code zu schrieben habe denn listbox.itemindex gibt es ja nicht. Ich frage mich wie ich das denn coden muss.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 21.02.05 23:25 
Hallo!

invulnerabilis hat folgendes geschrieben:
denn listbox.itemindex gibt es ja nicht.

Wie kommst du darauf? Die TListBox sollte über eine Eigenschaft mit der Beizeichnung ItemIndex verfügen.

Hier mal ein Beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  MessageDlg('Item ' + IntToStr (ListBox1.ItemIndex) + ' gewählt!', mtInformation, [mbOK], 0);
end;


Gruß
Tino
Christian V. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mo 21.02.05 23:30 
Komisch aber wahr, auf einmal sehe ich die eigenschaft, Danke jezt hats funktioniert.