如何只遍历TREEVIEW的最外层节点比如说, 我放了个按钮,并添加相应函数
BTN1CLIC(SENDER:TOBJECT)
BEGIN
// 做代码处理
END;当我没按下一次BTN1,在BTN1相应中得到依次从TREEVIEW中得到最外层的节点,并且依次遍历完所有的最外层节点。
并做保存。
BTN1CLIC(SENDER:TOBJECT)
BEGIN
// 做代码处理
END;当我没按下一次BTN1,在BTN1相应中得到依次从TREEVIEW中得到最外层的节点,并且依次遍历完所有的最外层节点。
并做保存。
Node:TTreeNode;
begin
Node := TreeView1.Items.GetFirstNode;
while Node <> Nil do
begin
ShowMessage(Node.Text);
Node := Node.getNextSibling;
end;end;
begin
LoadLastNode(TreeView1.Items.GetFirstNode);
end;procedure TForm14.loadLastNode(const ParentNode: TTreeNode); //
begin
if ParentNode = nil then
exit;
if ParentNode.getFirstChild = nil then //最外层就把text写入memo1,可以在这处理你的代码
Memo1.Lines.Add(ParentNode.Text)
else
loadLastNode(ParentNode.getFirstChild);
loadLastNode(ParentNode.getNextSibling);
end;
然后