开发者

TreeView: checkboxes only in child nodes

I need a treeview control:

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

C#, .n开发者_StackOverflowet 2.0, winforms (not wpf)


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


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;
        } 
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜