Optional Checkable Tree View Control for .NET Compact Framework 3.5

Windows MobileDuring this month I was working with my teammates Julian Dominguez and Diego Perez on a project that targeted Window Mobile 6.0 and the .NET Compact Framework 3.5. The main objective of this project was to create a module for an existing mobile application to let users perform different surveys and allowing them to navigate and filter through the questions and answers (between other things).

Among all the requirements for this project, there was one that asked for a view to show a hierarchical list of the questions / answers of the survey grouped by their types. The special thing about this view was that only some items of the hierarchical list should be checkable. Julian and I tried to use the TreeView control included in the .NET Compact Framework, but this control does not allow you to choose which items are checkable and which are not. So we decided to extend the default TreeView and create an optional checkable TreeView control. These were the results:

Tree View ControlsÂ

As you can see, in the default TreeView control (on the left) all the nodes has check boxes even the ones that are expandable. In the OptionalCheckableTreeView control (on the right) the expandable nodes are not checkable.

Implementation Details

Instead of setting the CheckBoxes property of the TreeView to true, we are using images to display the check boxes (either in checked or unchecked state) and the minus and plus icons to expand the tree.

To accomplish this we had to add support for the NodeMouseClick event, which is not available in the .NET Compact Framework. This event allows us to check / uncheck / expand / collapse the clicked node and also change the image index. We followed the guidance provided in the following articles in MSDN, with a few modifications:


Download the C# source code from here. The ZIP file contains the following:

  • OptionalCheckableTreeView.sln: Contains the source code for the OptionalCheckableTreeView control.
  • OptionalCheckableTreeView.Sample.sln: Contains a sample application that uses the OptionalCheckableTreeView control.
Note: This code is provided “AS IS” with no warranties, and confers no rights.

Feedback is always appreciated!


kick it on DotNetKicks.com

Leave a Reply