Autor Beitrag
Pott
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21

Windows
Delphi 5
BeitragVerfasst: Di 10.01.06 11:01 
Ich möchte bei jedem Knoten entscheiden, ob er aufgeklappt wird oder nicht (Feld 'Expand' aus Datenbank).

Nur funktioniert das mit Expand bei mir nicht. Entweder sind alle oder kein Knoten betroffen. Verwende ich die falschen Befehle?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
    ...
    with TreeView do
    begin
      Node := Items.AddChildObject(NewNode, NodeName, MyRecPtr);
      Node.ImageIndex   := MyRecPtr^.Icon;
      Node.SelectedIndex:= Node.ImageIndex;   
      //Node.Expanded:=MyRecPtr^.Expand;
      Node.Expand(qryTREE.FieldByName('Expand').AsBoolean);

      ReadNodes(Node, MyRecPtr^.Id);
      qryTREE.Next();
    end;
  end;


Moderiert von user profile iconTino: Delphi-Tags hinzugefügt
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: Di 10.01.06 12:52 
Hallo,

mit Node.Expand kannst Du nur Knoten expandieren.
Für das Ausblenden der Unterknoten ist Collapse zuständig.
Die Boolean-Variable beider Prozeduren bestimmen ob weitere Unterknoten mit berücksichtigt werden sollen, oder nicht.

Daher müsste das in etwa so aussehen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
//...
var MyRecPtr: PMyRec;
//...
if PMyRec(Node.Data)^.Expand then
  Node.Expand(False);//False nur eine Ebene wird expandiert

Das Expandieren kannst Du erst nach der Anlage der Unterknoten vornehmen.

Ps.: könntest Du deinen Code mit delphi-Tags formatieren? so [delphi]Code[/delphi] :arrow: BBCodes

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )