如何设置使在treeview中点击父节点,父节点下所有的子节点不可,点击子节点,该节点不可选。

再点一下,恢复原来的状态
2025-01-08 10:44:52
推荐回答(1个)
回答1:

protected void tree1_SelectedNodeChanged(object sender, TreeNodeEventArgs e)
{
TreeView tree= sender as TreeView ;
if(tree != null && tree.SelectedNode != null)
{
TreeNode parent = tree.SelectedNode;
foreach(TreeNode son in parent.ChildNodes)
{
//通过TreeNodeSelectAction控制节点状态
son..SelectAction=TreeNodeSelectAction.None;
}
}
}