3

I need a treeview control:

  1. Root nodes don't have checkboxes, only images.
  2. All child nodes have a checkbox + image.

C#, .net 2.0, winforms (not wpf)

nik
  • 875
  • 2
  • 12
  • 21

2 Answers2

3

The WinForms tree view does not support mixed checkbox/non checkboxes nodes by default

You can enable CheckBoxes globally on the tree view and disable them on specific nodes using this method

Community
  • 1
  • 1
vc 74
  • 37,131
  • 7
  • 73
  • 89
-1

You can disable checkbox. First Set TreeView DrawMode property as OwnerDrawAll. Then Under DrawNode method check child node collection and set checked property as false ie.

private void xmlStructureTree_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            if (e.Node.Nodes.Count != 0)
            {
                e.Node.Checked = false;
            }
            e.DrawDefault = true;
        } 
Linojan
  • 136
  • 1
  • 4
  • 10