ComboTree control is a control that combines the selection control with drop-down tree control. It is similar to ComboBox control but it does not have editing capabilities but it does have multiple column binding and auto grouping functionality built-in. Here is how ComboTree control looks like:

Clicking the drop-down button will show the tree control:

ComboTree can bind to any data source that supports IList or IListSource interfaces such as DataSet or an array. Here are steps to bind ComboTree to a data source:

  1. Set DataSource property to your data source
  2. Set DisplayMembers property to comma separated list of field names that you want to display on popup tree control. For example setting this property to ContactName,Phone will display these two fields on popup.
  3. Optionally set SelectedDisplayMemeber property to a field name that holds the selected value that you want displayed in control while popup is not visible.
  4. Optionally set ValueMember property to the field name that is used as actual value of the control. The ComboTree.SelectedValue property will return value of this field when selection changes.
  5. Optionally set GroupingMembers property to comma separated list of fields you want control to group data by. For example setting this property to Country will group the data on popup by country name. For alternative grouping option see next step.
  6. Optionally set ParentFieldNames property to comma separated field names that are used as identifiers for node and parent node. Format expected is: FieldNodeId,ParentNodeFieldId. For example if your table represents departments, you have DepartmentId field which uniquely identifies a department and ParentDepartmentId field which identifies parent of the department if any you would set this property to DepartmentId,ParentDepartmentId.
  7. If needed, handle SelectedIndexChanged event which occurs when selection in ComboTree changes.

When you set DisplayMembers property the control automatically generates the column and sets default size for them. In case that you want to set custom size for the columns or create them using code you must leave this property empty and manually create columns by using Edit Columns… command that is accessible if you right-click ComboTree in VS.NET designer or creating them using code.

For each new column header you create simply set Text property to the column header and DataFieldName property to the name of the field in your data source that holds the column value. You can change width of column by changing values on Width object.

You can control the drop down width and height by using DropDownWidth and DropDownHeight properties on ComboTree.

To control whether keyboard search is enabled use KeyboardSearchEnabled property. Keyboard search allows you to start typing while controls has focus and search the content of the control and select it based on the text you type.

Optional Buttons

You can display additional buttons or even hide default drop-down button by using ButtonClear, ButtonDropDown, ButtonCustom and ButtonCustom2 properties.

Related posts:

  1. How to create custom columns when binding data to AdvTree
  2. SuperGrid Quick Start Guide
  3. Micro-Charts for WinForms Quick Start Guide
  4. How to accept external drag & drop on TreeGX control
  5. WinForms Schedule Control Quick Start Guide