Autor Beitrag
Cix6
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Mo 10.04.06 09:18 
Hi,


wie kann ich bei einem OnClick auf ein Listview den Inhalt der Spalte 2 aus der aktuell angeklickten Zeile auslesen?

Cix6
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 10.04.06 09:45 
Moin!

Probier das mal so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.ListView1Click(Sender: TObject);
begin
  if Assigned(ListView1.Selected) then // ist was ausgewählt?
    if (ListView1.Selected.SubItems.Count > 0) then // 2. Spalte da?
      Label1.Caption := ListView1.Selected.SubItems.Strings[0];
end;

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Mo 10.04.06 09:52 
das funktioniert nicht...gibt nix aus!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 10.04.06 09:53 
Moin!

Mein Code funktioniert, habe ich vor dem Posten getestet. Zeig mal deinen... :|

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Cix6 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60

Windows XP
Delphi 4 Standard, Delphi 7 PE, Delphi 2005 PE
BeitragVerfasst: Mo 10.04.06 09:55 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.ListView1DblClick(Sender: TObject);
begin
if Assigned(ListView1.Selected) then // ist was ausgewählt?
    if (ListView1.Selected.SubItems.Count > 0) then // 2. Spalte da?
      form1.Caption := ListView1.Selected.SubItems.Strings[0];
end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 10.04.06 09:59 
Moin!

Nachwievor, der Code funktioniert. ;) Hast du überhaupt was in der 2. Spalte stehen?

cu
Narses

//EDIT: Na, haste den Fehler gefunden? ;) Du hattest die Doppelklick-Prozedur von ListView2, aber in deinem Code das stumpf von mir Kopierte drin, und das bezog sich auf ListView1... hab nämlich deinen Code vor deinem Editieren noch gesehen, da stand im Prozedurkopf eine "2" und keine "1" wie jetzt... :mrgreen:

Könntest dann noch den Thread als gelöst markieren; scheint ja wohl jetzt auch bei dir zu klappen. ;)

_________________
There are 10 types of people - those who understand binary and those who don´t.