我现在想要在treeview中添加节点时是往前面添加,请问怎么做?

解决方案 »

  1.   

    用 TreeView.Items.Insert(Node, Text); 在Node节点的前面插入节点。
      

  2.   

    TreeView.Items.addfirst  在第一个位置添加
    TreeView.Items.add  在最后一个位置添加
    TreeFriend.Items[i].MoveTo(TreeFriend.Items[i].Parent,naAddChildFirst);
    移动到
    那里,自己看一下参数TNodeAttachMode identifies a new or changed tree node relationship. UnitComCtrls or QComCtrlsDelphi syntax:enum TNodeAttachMode {naAdd, naAddFirst, naAddChild, naAddChildFirst, naInsert};C++ syntax:type TNodeAttachMode = (naAdd, naAddFirst, naAddChild, naAddChildFirst, naInsert);DescriptionThe TNodeAttachMode type specifies the way a new or relocated tree node will be related to some other node.Value MeaningnaAdd The new or relocated node becomes the last sibling of the other node.
    naAddFirst The new or relocated node becomes the first sibling of the other node.
    naInsert The new or relocated node becomes the sibling immediately before the other node.
    naAddChild The new or relocated node becomes the last child of the other node.
    naAddChildFirst The new or relocated node becomes the first child of the other node.