Autor Beitrag
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Do 21.10.04 16:28 
Hi
Ich möchte dem übergeordneten Knoten des Selektierten Knotens einen Knoten hinzufügen. :D
Ich weis das, dass mit ParentNode geht, aber wie benutzt man das?

ausblenden Delphi-Quelltext
1:
myNode:=TreeView1.Items.AddChild(TreeView1.Selected.ParentNode,ItemName);					


:?!?:
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 21.10.04 17:27 
Sieht doch völlig richtig aus. Wenn du bei ItemName noch deinen String für die Darstellung angibst, isses das doch schon.
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Do 21.10.04 17:57 
Zitat:
Undefinierter Bezeichner: 'ParentNode'


Muss ich vieleicht noch etwas in die uses einfügen?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 21.10.04 18:27 
Lass mal "Node" wech.
smiegel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 992
Erhaltene Danke: 1

WIN 7
D7 Prof., C#, RAD XE Prof.
BeitragVerfasst: Do 21.10.04 18:29 
Hallo,

ein Blick in die Delphi-Hilfe würde manchmal nicht schaden. :mahn:

Das was Du meinst ist nicht der ParentNode - deshalb die Fehlermeldung - sondern der Parent. Außerdem macht es Ssinn zu überprüfen, ob TreeView.Selected überhaupt auch ausgewählt ist:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var ItemName:String;
  ...
  if (TreeView1.Selected<>nil) then
  begin
    ItemName:='Knoten des Vaters';
    myNode:=TreeView1.Items.AddChild(TreeView1.Selected.Parent, ItemName);
  end; // if
  ...

_________________
Gruß Smiegel
Ich weiß, daß ich nichts weiß, aber ich weiß mehr als die, die nicht wissen, daß sie nichts wissen. (Sokrates)
Coder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Do 21.10.04 18:35 
Ah, danke!

Eigentlich hab ich in die Delphi-Hilfe geguckt, sonst wär ich garnicht auf ParentNode gekommen. Wusste aber auch garnich nach was ich eigentlich suchen sollte.

THX :D