Autor Beitrag
rafi@work
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Di 21.12.04 14:27 
Hallo zusammen

Wie kann ich folgendes bewerkstelligen?

- Ich klicke auf den Eintrag "Hallo" in der Listbox.
- Jetzt soll er mir das Subitem mit der Caption "Hallo" (ListView) in ein Edit feld schreiben.

Gruss
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Di 21.12.04 15:14 
ausblenden Delphi-Quelltext
1:
edit1.text := listbox1.items[listbox1.itemindex];					

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Di 21.12.04 15:16 
hallo rochus

nein ich will nicht denn itemindex, sondern den Text der dort steht
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Di 21.12.04 15:18 
du willst den text, der da steht, wo du hinklickst? das ist genau das, was mein quelltext macht.

über itemindex kriegst du den aktiven item, also der ItemIndex zeigt doch auf das angeklickte. und über den itemindex kommst du dann auf das, was drin steht: items[Zahl] -> listbox1.items[listbox1.itemindex]


gruß
rochus

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Di 21.12.04 15:22 
nein ich möchte, wenn ich in einer Listbox auf den Eintrag "hallo" klicke, dass er schaut wo die Caption in einer Listview "hallo" ist und dann soll er von der Listview mit der Caption Hallo den Text des zugehörigen Subitem[0] in ein editfeld reinschreiben.
rochus
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 416

Win XP Prof, Fedora Core 4, SuSE 7.0
D7 Ent, D2005 Pers
BeitragVerfasst: Di 21.12.04 15:29 
ach jetzat, nächstes mal sollt ich genauer lesen ;)

wie wärs, wenn du die items der listview durchgehst und nach der caption suchst?

ansonsten gibts noch Listview.Items.IndexOf(); der du ein object vom Typ TListItem übergeben musst. Hab ich aber noch nie gemacht, kann dir daher auch kein Code-Snippet geben.

gruß
rochus

_________________
Im Nachhinein ist man immer ein Schlauch!
"Dream as if you'll live forever, live as if you'll die today!" James Dean
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Di 21.12.04 19:22 
danke für deinen Vorschlag, versuche das grad mal umzusetzen :)
rafi@work Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 147

Win2000 Prof
D7 Enterprise
BeitragVerfasst: Mi 22.12.04 08:59 
Es hat geklappt. Habe es folgendermassen realisiert.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TFormStart.ListBoxReceiversClick(Sender: TObject);
var
  I : integer;
  selected : integer;
begin
  For i := 0 to FormReceivers.ListViewReceivers.Items.Count-1 do
  begin
    If ListBoxReceivers.Selected[i] = true then
    begin
      Edit1.Text := FormReceivers.ListViewReceivers.Items.Item[i].SubItems[0];
    end;
  end;
end;