日期:2014-05-18 浏览次数:21332 次
/// 节点的展开和折叠 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tvDocInfo_AfterExpand(object sender, TreeViewEventArgs e) { if (e.Node.Parent == null) { TreeView tree = (TreeView)sender; tree.AfterCheck -= new TreeViewEventHandler(this.tvDocInfo_AfterExpand); //折叠其他同级节点 TreeNode parentNode = e.Node.Parent; if (parentNode != null) { foreach (TreeNode tn in parentNode.Nodes) { if (tn != e.Node) tn.Collapse(); } } else { foreach (TreeNode tn in tree.Nodes) { if (tn != e.Node) tn.Collapse(); } } } }