简体   繁体   English

TreeView:仅在子节点中的复选框

[英]TreeView: checkboxes only in child nodes

I need a treeview control: 我需要一个treeview控件:

  1. Root nodes don't have checkboxes, only images. 根节点没有复选框,只有图像。
  2. All child nodes have a checkbox + image. 所有子节点都有一个复选框+图像。

C#, .net 2.0, winforms (not wpf) C#,。net 2.0,winforms(不是wpf)

The WinForms tree view does not support mixed checkbox/non checkboxes nodes by default 默认情况下,WinForms树视图不支持混合复选框/非复选框节点

You can enable CheckBoxes globally on the tree view and disable them on specific nodes using this method 您可以在树视图上全局启用CheckBox,并使用此方法在特定节点上禁用它们

You can disable checkbox. 您可以禁用复选框。 First Set TreeView DrawMode property as OwnerDrawAll . 首先将TreeView DrawMode属性设置为OwnerDrawAll Then Under DrawNode method check child node collection and set checked property as false ie. 然后在DrawNode方法下检查子节点集合并将checked属性设置为false即。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM