title: Tri-State Checkboxes in WinForms TreeView
body: <p>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 that have children using the <a href="https://stackoverflow.com/questions/698369/how-to-disable-a-winforms-treeview-node-checkbox">checkbox hiding technique from another question</a>, like so:</p>
  
  <pre><code>☑ Node 1
  ☐ Node 2
  • Node 3
    ☑ Node 3.1
    ☑ Node 3.2
  • Node 4
    ☐ Node 4.1
    ☑ Node 4.2
  </code></pre>
  
  <p>But a better solution would be to use tri-state check boxes for the parent nodes, like this:</p>
  
  <pre><code>☑ Node 1
  ☐ Node 2
  ☑ Node 3
    ☑ Node 3.1
    ☑ Node 3.2
  ☒ Node 4
    ☐ Node 4.1
    ☑ Node 4.2
  </code></pre>
  
  <p>Since this functionality was available in Win32, my question is how to do this without drawing the boxes myself (e.g., as a user-drawn control or <a href="http://www.codeproject.com/KB/tree/treeviewex2003.aspx?display=Print" rel="nofollow noreferrer">using an image list</a>). I am not familiar with the Win32 API at all; how would one extend the technique linked above to enable tri-state checboxes on a managed TreeView control?</p>