Tri-State Checkboxes in WinForms TreeView

前端 未结 3 1699
离开以前
离开以前 2020-12-29 09:30

I have a TreeView that allows users to select certain elements of hierarchical data by checking or un-checking each item\'s checkbox. Currently I disable the box on nodes th

相关标签:
3条回答
  • 2020-12-29 10:10

    This code might help you if you are thinking of drawing the mixed checkbox

    class MixedCheckBox:Control
    {
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(0, 0), Bounds, 
                Text, Font, false, 
                System.Windows.Forms.VisualStyles.CheckBoxState.MixedNormal);
        }
    }
    

    This will render: enter image description here

    Good luck!

    0 讨论(0)
  • 2020-12-29 10:24

    There is now a neat looking solution at Code Project, Tri-State Tree View

    I'm just researching at the moment, so haven't yet used it.

    0 讨论(0)
  • 2020-12-29 10:29

    Have you taken a look at this? It seems to do the job. It might be a bit dated, (looks like the article is from 2004), but I'm sure the same principles can be extended to whatever you need to do.

    0 讨论(0)
提交回复
热议问题