3

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?

user449921
  • 241
  • 1
  • 4
  • 14
  • possible duplicate of [How can I control checkboxes in a .Net Forms.TreeView?](http://stackoverflow.com/questions/39119/how-can-i-control-checkboxes-in-a-net-forms-treeview) – Adam Lear Dec 17 '10 at 23:24

2 Answers2

4

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?

Community
  • 1
  • 1
Adam Lear
  • 38,111
  • 12
  • 81
  • 101
2

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.

Community
  • 1
  • 1
Philip Hanson
  • 1,847
  • 2
  • 15
  • 24