Autor Beitrag
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 23.10.03 14:45 
Hallo !!!

ich hab schon das komplette forum abgesucht aber nix hilfreiches gefunden.
ich habe folgendes problem:

ich habe eine liste die sieht so aus:
a|hallo
b|test2
a|test3

so ich will diese liste in einem treeview darstellen.

jetzt kann man ja im treeview einen node folgendermasen hinzufühen:
ausblenden Delphi-Quelltext
1:
2:
3:
var tn: Ttreenode;
tn := treeview1.Items.Add (nil,'hallo');
tn := treeview1.Items.AddChild (tn,'test');


klar. dann bekomm ich ja einen knoten un ein unteritem.
nur:

wie mache ich das, dass ich für jedes a,b,...x,y,z einen node anlegen kann wenn ich die liste durchgehe und dann einen unterpunkt hinzufügen kann.
also wie prüfe ich ob schon ein knotenpunkt mit der caption a,b oder so vorhanden ist und wenn ja wie kann ich dem dann unteritems zurdnen ??

uff.

_________________
In the beginning was the word.
And the word was content-type: text/plain.


Zuletzt bearbeitet von matze am Fr 24.10.03 15:14, insgesamt 1-mal bearbeitet
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 23.10.03 16:22 
Wenn ich ehrlich bin hab ich das Probelm nicht verstanden... :cry:
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 23.10.03 16:36 
ja mir ists da als ich das geschrieben hab nix besseres eingefallen.

das problem ist also auf deutsch:

wie kann ich prüfen (mit einem stringwert) ob ein treenode schon vorhanden ist,
wenn ja: soll das aproggi unter diesem node neue untereinträge anlegen,
falls nein: soll es den hauptnode anlegen und dann untereinträge anlegen.


das also aus einner liste die so aussieht:
ausblenden Quelltext
1:
2:
3:
4:
a|matze
b|tino
a|luckie
b|marc

ein solcher treeview wird:

a-
|- matze
|- luckie
b-
|-tino
|-marc

_________________
In the beginning was the word.
And the word was content-type: text/plain.
SlasHeR
Hält's aus hier
Beiträge: 8



BeitragVerfasst: Do 23.10.03 16:50 
Hi matze.
Ich hatte ein ähnliches Problem, da hab ich mir einfach ein neues Steuerelement runtergeladen:
www.torry.net/vcl/lv...s/pgpathtreeview.zip

Da kannst du mit Tree.DestPath := 'a|b|c';
einen pfad zuweisen, als seperator gibst du an | und er fügt dir alles automatisch ein.
also keine doppelten eintraege ;)
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 23.10.03 18:27 
hm ja gut ich werd mir die kompo mal anschaune, allerdings mag ich nicht schon wieder eine komponente installieren. das muss doch auch anders gehen !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Shark
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 87

98, XP
D3, D5, D7
BeitragVerfasst: Do 23.10.03 19:48 
TreeNodes haben die Eigenschaft Level, mit der Du die Ebene herausfindes...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
function findNode(Text: string; Level: integer): TTreeNode;
  var index: integer;
        node: TTreeNode;
begin
  result := nil;
  for index := 0 to TreeView.Items.Count - 1 do
  begin
    node := TreeView.Items[index];
    if (Node.Level = Level) and (Node.Text = Text) then
    begin
      result := Node;
      break;
    end;

  end;

end;
matze Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 24.10.03 15:13 
suuuuuuuuuuper !!!!

das ist genau das was ich mir gewünscht hab !!!!!

du bist der beste !!!!

danke !

_________________
In the beginning was the word.
And the word was content-type: text/plain.