Autor Beitrag
Muetzi
Gast
Erhaltene Danke: 1



BeitragVerfasst: Fr 21.11.03 13:57 
hi,

ich hab eine treeview und füge dieser subitems hinzu, dabei tritt aber ein kleines problem auf...

Beispiel:
ausblenden Quelltext
1:
2:
Hauptthema1
Hauptthema2


Wenn ich jetzt Hauptthema1 einen Eintrag hinzufüge ändert sich automatisch der itemindex, so dass ich keinerlei einträge mehr dem hauptthema 2 hinzufügen kann..

Es läuft alles in einer schleife...

ausblenden Delphi-Quelltext
1:
treeview1.Items.AddChild(treeview1.Items[i],str1);					


Der zweite Eintrag der dann im Hauptthema2 stehen soll, steht dann im sub menü des ersten submenüs..hoffe das ist verständlich.

Es sind dann im endefekt so aus:

ausblenden Quelltext
1:
2:
3:
4:
Hauptthema1
         Subitem1
               Subitem2
Hauptthema2



Sollte aber so aussehen:
ausblenden Quelltext
1:
2:
3:
4:
Hauptthema1
        Subitem1
Hauptthema2
        subitem2


Gruß

muetzi
iKilledKenny
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 394
Erhaltene Danke: 8

Win XP
D5 Prof, C# Express 2005
BeitragVerfasst: Fr 21.11.03 16:05 
hallo muetzi,

ich vermute mal mit deiner schleife stimmt was nicht.
poste mal den code, wo du die treeview füllst.
Muetzi
Gast
Erhaltene Danke: 1



BeitragVerfasst: So 23.11.03 20:37 
meine schleife ist in etwa so...

ausblenden Quelltext
1:
2:
3:
4:
for x := 0 to 7 do
begin
form1.tv1.Items.AddChild(form1.tv1.Items[x],str1)
end;



kann mir jemand helfen?

Gruß

Muetzi
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: So 23.11.03 20:51 
Hi!

Du brauchst die GetNextSibling Methode
(Returns the next node in the tree view at the same level as the calling node. )

Dann sieht's etwa so aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
  Node: TTreeNode;
  x: Integer;
begin
  Node :=  TreeView1.Items[0];
  for x := 0 to 7 do
  begin
    TreeView1.Items.AddChild(Node,'123');
    Node := Node.GetNextSibling;
  end;
end;
Ist die Frage beantwortet? Das Problem gelöst?

Dann klicke hier, um das Thema entsprechend zu markieren!