开发者

C# treeview node

开发者 https://www.devze.com 2023-01-16 17:53 出处:网络
I have a treeview1: treenode-- 开发者_StackOverflow社区treenode1-- treenode2 treenode3 You can select only node2 and node3 if you want to display them parameters. How can i block selecting node and

I have a treeview1:

             treenode--
               开发者_StackOverflow社区   treenode1--
                     treenode2
                     treenode3

You can select only node2 and node3 if you want to display them parameters. How can i block selecting node and node1? I try like that,but than you can select all nodes:

    private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
    {
    ...
     }


you will have to use SelectAction Property on the tree node. you will need to set it on the node when you are creating them.

set selectaction=none on node and node1


If it's a win forms TreeView handle the BeforeSelect event and set the Cancel property of your TreeViewCancelEventArgs parameter to false. For web controls see Vinay's answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号