开发者

C# checkboxes in treeview

开发者 https://www.devze.com 2023-01-31 08:43 出处:网络
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:

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

                   -No开发者_如何学运维de 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.

0

精彩评论

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

关注公众号