Hi Pieter,
Have just downloaded and checked with the latest version (1.1.4.10) and still having the problem.
Add a TAdvTreeview to a blank form, with 3 buttons.
To initialise the treeview, add the following code to Button1Click
procedure TForm9.Button1Click(Sender: TObject);
var TmpNode: TAdvTreeviewNode;
begin
with AdvTreeview1 do
begin
ClearNodes;
ClearColumns;
Columns.Add.Text:='Nodes';
Columns.Add.Text:='Data';
{ top level }
TmpNode:=Nodes.Add;
with TmpNode do
begin
Text[0]:='Level 0';
DataInteger:=1;
Text[1]:='101';
Values[1].DataInteger:=101;
end;
{ second level }
TmpNode:=TmpNode.Nodes.Add;
with TmpNode do
begin
Text[0]:='Level 1';
DataInteger:=2;
Text[1]:='102';
Values[1].DataInteger:=102;
end;
{ third level - 3 nodes }
with TmpNode.Nodes.Add do
begin
Text[0]:='Level 2a';
DataInteger:=3;
Text[1]:='103';
Values[1].DataInteger:=103;
end;
with TmpNode.Nodes.Add do
begin
Text[0]:='Level 2b';
DataInteger:=4;
Text[1]:='104';
Values[1].DataInteger:=104;
end;
with TmpNode.Nodes.Add do
begin
Text[0]:='Level 2c';
DataInteger:=5;
Text[1]:='105';
Values[1].DataInteger:=105;
end;
end;
end;
To reparent the level 2 nodes, add the following code to Button2Click
[code]
procedure TForm9.Button2Click(Sender: TObject);
var NewParent,OldParent:TAdvTreeviewNode; var N:integer;
begin
with AdvTreeview1 do
begin
NewParent:=Nodes[0];
OldParent:=Nodes[0].Nodes[0];
for N:=OldParent.GetChildCount-1 downto 0 do
begin
OldParent.Nodes[N].MoveTo(NewParent,0);
end;
OldParent.Free;
end;
end;
{/CODE]
Finally, to see the values of DataInteger, add the following code to Button3Click
procedure TForm9.Button3Click(Sender: TObject);
var S1,S2:string; Node:TAdvTreeviewNode;
begin
with AdvTreeview1 do
begin
S1:=''; S2:='';
Node:=GetFirstRootNode;
while Node<>NIL do
begin
S1:=S1+Node.DataInteger.ToString+' ';
S2:=S2+Node.Values[1].DataInteger.ToString+' ';
Node:=Node.GetNext;
end;
ShowMessage(S1+#13+S2);
end;
end;
Click Button1 to init the treeview.
Click Button3 to see the DataInteger values, should see
1 2 3 4 5
101 102 103 104 105
Click Button2 to reparent the level 2 nodes to the top level node and delete the original parent.
Click Button3 to see the DataInteger values: expecting:
1 3 4 5
101 103 104 105
Actually get:
1 3 4 5
101 0 0 0
The Node.Values[1].DataInteger value is getting lost during the reparent
The Node.DataInteger value is ok!