简体   繁体   中英

C# checkboxes in treeview

I use a treeview in my application (C#, gui). I want to hide checkboxes in 'Node 1' and in 'Node 1.1.1'. How can i do it? My treeview looks like that:

TreeView 1

   -Node 1

      - Node 1.1

              -Node 1.1.1

                   -Node 1.1.1.A

                   -Node 1.1.1.B

              -Node 1.1.2

                   -Node 1.1.2.A 

I use :

treeview1.checkboxes = true;

to show all checkboxes, but how can i hide someone?

Unfortunately no, not without subclassing TreeView and overriding some of the control painting.

This question's accepted answer has the information you need: How can I control checkboxes in a .Net Forms.TreeView?

The answer to this question is one option: How to disable a WinForms TreeView node checkbox? However, it involves calling out to the Win32 API.

Alternately, you could subclass the control and draw the check boxes yourself. This way is pretty much the only option if you need more advanced stuff like tri-state check boxes. There are several examples like this one on CodeProject of ways to do that.

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