简体   繁体   中英

C# treeview node

I have a treeview1:

             treenode--
                  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM