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

WinXP
D2005 PE
BeitragVerfasst: Sa 28.10.06 21:46 
Edit// Thema verfehlt.
Ich hab VirtualTreeView mal mit Objekten benutzt.
Vielleicht hilft dir das ja weiter:
www.delphi-forum.de/....php?p=367721#367721

MfG


Zuletzt bearbeitet von Coder am Sa 28.10.06 22:18, insgesamt 2-mal bearbeitet
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Sa 28.10.06 22:11 
Moin!

@user profile iconCoder: Sag mal, hat user profile iconTimKellner eigentlich jemals was von VirtualTreeView gesagt... ? :gruebel:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Sa 28.10.06 22:15 
Edit// Thema verfehlt.
Oh verdammt :autsch:
Wieso hab ich mich schon gewundert? :autsch:
Son mist :autsch:
Ignoriert mich einfach ok? :autsch:
(Ich bin ein Schlauch)
TimKellner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 73

Win XP Pro
Delphi 7 Enterprise, RAD Studio
BeitragVerfasst: Sa 28.10.06 23:46 
Nabend

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
TreeView_List.Items.Clear;
  node := TreeView_list.Items.AddChild(nil,'Übersicht');
  TreeView_List.Items[0].ImageIndex := 9;
  TreeView_List.Items[0].SelectedIndex := 9;
  Form_Login.IdTCPClient1.WriteLn('dbserverlist');
  i := 1;
  repeat
    if i = 1 THEN response := Form_Login.IdTCPClient1.ReadLn;
    response := Form_Login.IdTCPClient1.ReadLn;
    if Response = 'OK' then
    begin
      ende := true;
    end
    else
    begin
      fserver := TServer.Create;
      server := TStringList.Create;
      try
      server.CommaText := response;
      fserver.Name := server.Strings[0];
      fserver.Data).Port := server.Strings[1];
      fserver.Name := server.Strings[2];
      fserver.Status := server.Strings[3];
      finally
      server.Free;
      TreeView_List.Items.AddChild(node,fserver.Port);
      if TreeView_List.Items[i].Level <> 0 THEN
      begin
        if fserver.Status = '1' THEN
        begin
          TreeView_List.Items[i].ImageIndex := 8;
          TreeView_List.Items[i].SelectedIndex := 8;
        end
        else
        begin
          TreeView_List.Items[i].ImageIndex := 7;
          TreeView_List.Items[i].SelectedIndex := 7;
        end;
      end;
    end;
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 29.10.06 00:01 
Moin!

Probier das mal so in der Art:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
  var
    Root, Node: TTreeNode;
    FServer: TServer;
begin
  TreeView_List.Items.Clear;
  Root := TreeView_list.Items.Add(NIL,'Übersicht');
  Root.ImageIndex := 9;
  Root.SelectedIndex := 9;

  FServer := TServer.Create;
  FServer.Name := 'hostname';
  FServer.Port := '1234';
  FServer.Status := '1';
  Node := TreeView_List.Items.AddChild(Root,FServer.Port);
  Node.Data := FServer;

Jetzt hast du eine Referenz auf die Instanz von TServer mit im Knoten und kannst darauf zugreifen. Allerdings darauf achten, dass du entweder die erzeugen Instanzen von TServer irgendwo sammelst und dann später auch wieder freigibst oder das Löschen des TreeViews so erweitern, dass die dranhängenden Objekte auch wieder freigegeben werden. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 29.10.06 00:19 
user profile iconNarses hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
  Node := TreeView_List.Items.AddChild(Root,FServer.Port);
  Node.Data := FServer;

Das geht doch kürzer... :gruebel: ... Ahh :idea:
ausblenden Delphi-Quelltext
1:
  Node := TreeView_List.Items.AddChildObject(Root,FServer.Port,FServer);					

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 29.10.06 00:40 
Moin!

@user profile iconMartok: Ja, klar geht das kürzer (dann kannst du auch noch das "Node :=" gelassen :idea:), aber macht dann die Technik nicht so schön klar, wie in meiner Version. ;) Und an genau diesem Verständis haperte es ja hier... :D

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 29.10.06 00:47 
Stimmt.

Mal n bisschen OT: man könnte ja mal einen Wettbewerb machen: ein bestimmtes Problem ist von mehreren Programmierern auf verschiedenen Erfahrungs-Leveln zu lösen. Dann wird der Programmierstil verglichen, und das einfachste, verrückteste usw. prämiert.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."