tags:

views:

113

answers:

2

Here is what I am looking to do:

  • Represent a set of options, divided by category.
  • Allow the user to check/uncheck all items within a category by checking/unchecking the category node.
  • Show that some options within a category are checked by setting the category node to an intermediate checked state.

From what I've read, and my limited experience with TreeViews, this last desirable doesn't appear possible, as TreeNodes don't seem to support anything other than a on/off checked state. Is this possible using a TreeView? Is there some other control that could pull this off, or am I going to have to make a sub-class of TreeView to get it done?

A: 

I think you'll have to write that feature yourself. You could keep it simple and just colour the checkbox a light gray or something to show an intermediate state.

If you're using WPF, I think you might be able to alter the control template of the treeview and/or the control template of the checkbox.

In WPF I would say it would be easier to implement then winforms. Not sure what technology you're using in this case.

Tony
+2  A: 

It can be done by using the DrawMode property so you can paint your own check box with ControlPaint.DrawCheckBox(). You'll also have to implement the MouseDown event and use the HitTest method to detect clicks on the fake checkbox. No great joy, but it's possible.

Hans Passant