首页  编辑  

TreeView互斥展开

Tags: /C#/界面处理/ListView_TreeView/   Date Created:

private void CollapseNode( TreeNode ATreeNode)

{

    if (ATreeNode == null ) return ;

    TreeNodeCollection vNodes;

    if (ATreeNode . Parent != null )

       vNodes = ATreeNode . Parent . Nodes;

    else vNodes = ATreeNode . TreeView . Nodes;

    foreach ( TreeNode vTreeNode in vNodes)

   {

        if (vTreeNode != ATreeNode)

           vTreeNode . Collapse();

   }

}

private void treeView1_AfterExpand( object sender , TreeViewEventArgs e)

{

   CollapseNode(e . Node);

}