Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Fr 06.03.09 18:03 
Hallo,

mit folgenden Code versuche ich vergeblich in der 2. Spalte des markierten Row den
Text X reinzuschreiben. Es kommt immer ein Fehler "Listenindex überschreitet das maximum (0).
Es gibt aber 2 Spalten.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
  aItem: TListItem;
begin
  if ListView1.SelCount = 1 then
  begin
   if ListView1.Selected <> nil then
    begin
    aItem := ListView1.Selected;
    aItem.SubItems[0] := 'X';
    end;
  end;
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: Fr 06.03.09 18:12 
Hallo,

mag ja sein, das es 2 Spalten gibt, aber das bedeutet noch nicht, das in der 2. Spalte auch was steht. Das subitem muß auch angelegt sein!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var  aItem: TListItem;
begin
  if ListView1.SelCount = 1 then
   if ListView1.Selected <> nil then    
     begin    
       aItem := ListView1.Selected;
       if aitem.subitens.count>0 then
         aItem.SubItems[0] := 'X'
        else
         aItem.SubItems.add('X');
     end;  
end;


Gruß Frank

_________________
Lükes Grundlage der Programmierung: Es wird nicht funktionieren.
(Murphy)