- 3 minutes to read
The Tree List control displays data by means of nodes and columns. If the control is bound to a data source, columns represent fields while nodes correspond to records.
The Tree List control stores columns in the TreeList.Columns collection. Each column, represented by a TreeListColumn class object, provides properties to specify the column's visibility, display caption, width, in-place editor, appearance and formatting settings, etc. However, the column's main property is TreeListColumn.FieldName. In bound mode, it specifies the data source field whose data is displayed in the current column.
You can access columns via the indexer provided by the TreeList.Columns collection. The indexer accepts either the index of the column or the name of the bound field. TreeListColumn objects are components. So, if columns are created at design time, you can access them by names in code, like other components.
The focused column can be accessed via the TreeList.FocusedColumn property. Together with the focused node (TreeList.FocusedNode), the focused column identifies the currently focused cell. If you want to move focus to another column, assign this column to the TreeList.FocusedColumn property.
The position of columns within the TreeList.Columns collection does not specify their visible order. The visual position of a column is specified via its TreeListColumn.VisibleIndex property. Set this property to -1, to hide the column. Setting it to a non-negative integer makes it visible again.
End-users have the ability to customize the layout of columns at runtime (rearrange, hide and restore columns). To rearrange columns, they can use drag-and-drop. To hide certain columns, they need to invoke the Customization Form and drag columns by their header from the Tree List control onto the Customization Form.
To access and restore hidden columns, end-users need to again display the Customization Form, and drag columns back from the form to the Tree List control. Note that moving columns to/from the Customization Form modifies the TreeListColumn.VisibleIndex property.
By default, columns are proportionally resized to fit the Tree List control's width in its entirety. You can disable this feature via the TreeListOptionsView.AutoWidth property. In this instance, columns will have the exact width specified by the TreeListColumn.Width property.
The TreeListColumn.OptionsColumn property provides access to the following settings applied to the column:
- AllowEdit — Specifies whether the column is editable. The TreeList.OptionsBehavior.Editable property disables editing all columns in the control.
- AllowFocus — Specifies whether the column can be focused.
- AllowMove — Specifies whether the column can be dragged to a new position.
- AllowMoveToCustomizationForm — Specifies whether the column can be hidden to the Customization Form.
- AllowSize — Specifies whether the column can be resized.
- AllowSort — Specifies whether the column can be sorted.
- FixedWidth — Specifies whether the column's width is fixed. See Fixed Columns to learn more.
- ReadOnly — Specifies whether the column is read-only.
- ShowInCustomizationForm — Specifies whether the column, when it's hidden, is listed in the Customization Form.
A column's appearance can be modified by:
Assigning an editor to a column.
The assigned editor is used to edit values of the column's cells, and it specifies the column's values formatting and representation. See Inplace Editors to learn more.
Customizing appearance settings.
Use the TreeListColumn.AppearanceCell or TreeListAppearanceCollection.Row property to customize the appearance of a column's cells. The appearance of the column's header can be specified via the TreeListColumn.AppearanceHeader and TreeListAppearanceCollection.HeaderPanel properties. See Appearances, for additional information.
Formatting column values.
Please refer to the Formatting Cell Values topic, for details.