Disable or grey out a node in the TreeNode Editor

前端 未结 4 887
遥遥无期
遥遥无期 2021-01-03 21:12

How do I disable a specific node so the user can not select it. Hiding it for the user is also valid.

I tried the Visible property but that hides the entire tree (al

4条回答
  •  一整个雨季
    2021-01-03 21:51

    I just found another way to handle the disabled treenodes. If you gray in the treenodes you don't want to use, you can ask for the color and not allow all grayed nodes.

        private void TreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            if(SystemColors.GrayText==e.Node.ForeColor)
                e.Cancel = true;
        }
    

提交回复
热议问题