Devexpress TreeList 展开和折叠当前选中节点
1.展开:
1 private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) 2 { 3 ParentNodeExpend(treeListEstateInfo.FocusedNode); 4 } 5 /// <summary> 6 /// 展开当前节点及父节点 7 /// </summary> 8 /// <param name="_node"></param> 9 public void ParentNodeExpend(TreeListNode node) 10 { 11 TreeListNode _cNode = node; 12 treeListEstateInfo.Nodes.TreeList.FindNodeByID(_cNode.Id).Expanded = true; 13 while (_cNode.ParentNode != null) 14 { 15 treeListEstateInfo.Nodes.TreeList.FindNodeByID(_cNode.ParentNode.Id).Expanded = true; 16 _cNode = _cNode.ParentNode; 17 } 18 }
2.折叠
1 private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) 2 { 3 CloseFocuseNode(treeListEstateInfo.FocusedNode); 4 } 5 /// <summary> 6 /// 折叠当前选中节点 7 /// </summary> 8 /// <param name="_node"></param> 9 public void CloseFocuseNode(TreeListNode node) 10 { 11 treeListEstateInfo.Nodes.TreeList.FindNodeByID(node.Id).Expanded = false; 12 }
作者:江宁织造
博客:http://www.cnblogs.com/wgx0428/
博客:http://www.cnblogs.com/wgx0428/