Autor Beitrag
Gabberman
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55



BeitragVerfasst: Mo 23.10.06 20:33 
Hy @ all,
ich hab da mal eine Frage an euch. Ich hab ein Programm geschrieben, bei dem der Benutzer einen Eintrag in ein TreeView hinzufügen kann... Soweit so gut. Jetzt zu meiner eigentlichen Frage: Ein Eintrag ist nun bekannt (wird ausgewählt vom User), soll in dem TreeView gesucht werden und diesem Eintrag ein Child hinzugefügt werden!!! (Auch dieses Child gibt der User selbst ein!)

Weiß jemand wie das geht?!

Es wär echt super wenn ihr mir diese Frage beantworten könntet!!!

Danke

Gabberman
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 23.10.06 20:44 
Moin!

Probier das mal so:
ausblenden Delphi-Quelltext
1:
TreeView1.Items.AddChild(TreeView1.Selected,'Neu');					

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 23.10.06 20:44 
Hallo,

schau mal hier in der Delphi-Library nach, der erste Beitrag.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Gabberman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55



BeitragVerfasst: Mo 23.10.06 20:49 
user profile iconNarses hat folgendes geschrieben:
Moin!

Probier das mal so:
ausblenden Delphi-Quelltext
1:
TreeView1.Items.AddChild(TreeView1.Selected,'Neu');					

cu
Narses


Hm, ne das geht nicht ganz so. Der fügt irgendwie kein Child hinzu. Also nur das wir uns richtig verstehen: Ein Child ist bei mir ein Eintrag der unter einem anderem Root-eintrag erscheint und diesem zugeordnet ist. Bei deiner Variante erscheint da aber ein neuer Root-eintrag...
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 23.10.06 20:53 
Moin!

Das hier:
ausblenden Delphi-Quelltext
1:
TreeView1.Items.AddChild(TreeView1.Selected,'Neu');					

bewirkt, dass der neue Eintrag an den aktuell ausgewählten angehängt wird. Ist nix ausgewählt, wird also ein Root-Eintrag angelegt - völlig korrekt. ;)

Klick mal einen Eintrag an und führ dann den Code aus. :D

cu
Narses

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



BeitragVerfasst: Mo 23.10.06 20:55 
user profile iconNarses hat folgendes geschrieben:
Moin!

Klick mal einen Eintrag an und führ dann den Code aus. :D


ACHSO!!! Verstehe... Kann man das aber so machen das das an den eingegebenen String angehangen wird?!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 23.10.06 20:57 
Moin!

Klar, selektier halt den entsprechenden Node im TreeView oder übergib einfach nur die Referenz dazu, statt .Selected. ;)

cu
Narses

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



BeitragVerfasst: Mo 23.10.06 21:00 
user profile iconNarses hat folgendes geschrieben:

Klar, selektier halt den entsprechenden Node im TreeView oder übergib einfach nur die Referenz dazu, statt .Selected. ;)


Irgendwie hab ich grad das Gefühl das ich mich sehr dähmlich anstelle, aber irgendwie hab ich keinen blassen Schimmer wie ich das machen soll!!! Kannst du mir da bitte noch mal helfen?!
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 23.10.06 21:02 
Moin!

Schau mal in den Link von user profile iconLannes, da wird das erklärt. ;)

cu
Narses

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



BeitragVerfasst: Mo 23.10.06 21:16 
Hm, also ich hab mir den Code jetz mal angeschaut.... Eigentlich hatte ich ja gehofft, dass mir jemand eine einfachere lösung bieten könnte, aber naja :(
Da dies ja nicht der Fall ist, hab ich noch ein paar Fragen zu dem Quelltext, bei denen hoffentlich noch jemand die Nerven hat, diese mir zu beantworten:
Was soll dieser "Delimiter", also was bringt der genau. Und wo kann ich festlegen, was hinter den Knotenpunkt geschrieben wird?!?!

Danke
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 23.10.06 21:44 
Hallo,

mit dem Delimeter trennst Du die einzelnen Nodes.

Angenommen Du hast folgendes im TreeView stehen:
ausblenden Quelltext
1:
2:
Gerd  
--Mustermann

Daran soll jetzt Wohnhausen angehängt werden, damit es dann so aussieht:
ausblenden Quelltext
1:
2:
3:
Gerd  
--Mustermann
----Wohnhausen


Dafür müsste der Funktionsaufruf dann so aussehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var ReNode : TTreeNode;  
    Path : String;  
begin  
  Path := 'Gerd\Mustermann\Wohnhausen';  
  AddTreeNodePathDupIgnore(TreeView1,Path,'\',ReNode,AddSort);  
end;


Eine einfachere Lösung ist möglich wenn es in allen Ebenen des TreeView keine doppelt vorhandenen Nodes gibt.
Dann eine Schleife durch das TreeView laufen lassen, den Node suchen und das neue Child anhängen.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Gabberman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55



BeitragVerfasst: Mo 23.10.06 21:54 
Zitat:
Eine einfachere Lösung ist möglich wenn es in allen Ebenen des TreeView keine doppelt vorhandenen Nodes gibt.
Dann eine Schleife durch das TreeView laufen lassen, den Node suchen und das neue Child anhängen.

Dieser Fall ist vorliegend!!!!!!!

Aber wie soll jetzt diese Schleife aussehen?!
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Mo 23.10.06 22:49 
Hallo,

so ähnlich:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
for z := 0 to TreeView1.Items.Count -1 do
  if TreeView1.Items[z].Text = 'DaDranHängen' then
    begin
    TreeView1.Items.AddChild(TreeView1.Items[z],'Neu');
    break;   
    end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
Gabberman Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 55



BeitragVerfasst: Di 24.10.06 11:42 
GANZ GROßE KLASSE!!! DANKE FÜR EURE HILFE... HAT MICH ECHT WEITERGEBRACHT!!!