Version

Sort Columns in WinTree

Previous versions of the WinTree™ included the ability to sort nodes programmatically based on the Text property of the node. With the addition of column support in Ultimate UI for Windows Forms 2005 Volume 2, the WinTree now also includes the ability to sort the nodes based on the values of cells in particular columns. The sort order can be controlled programmatically but may also be changed at runtime by clicking on the column headers.

By default, multi-column sorting is enabled at runtime. When multi-column sorting is enabled, clicking on a column header without holding the {Shift} key will clear the SortedColumns of the associated UltraTreeColumnSet and add that column to the collection. If the column was already sorted, the SortType , which is the property that indicates the sort direction, would be toggled from Ascending to Descending or vice versa. If the column was not already sorted, the SortType would be initialized to Ascending. Clicking on a column header while holding the {Shift} key would prevent the SortedColumns collection from being cleared. Instead, the column would be added to the end of the collection. As occurs when not holding the Shift key, if the column was already sorted, the SortType would be toggled from Ascending to Descending or vice versa but the column would still be moved to the end of the SortedColumns collection.

To prevent the end-user from changing the sort via the UI, you can set the AllowSorting property on either a specific column (using the column’s AllowSorting ), the entire ColumnSet (using the ColumnSet’s AllowSorting ) or for all ColumnSets (using the ColumnSetting’s AllowSorting property).

Note
Note

By default, the modifier key for adding to the SortedColumns collection is the {Shift} key but this can be changed using the MultiSortModifierKey property.

  1. We will start with a WinTree that looks similar to the one shown in the screenshot below.

starting organization of ultratree in grid style
  1. Click on the Last Name to sort by that column’s values. The tree will look similar to that below.

ultratree sorted by last name column
  1. If you wanted to change the sort order to only sort by the First Name, you would simply click on the First Name column. However, to sort by both the Last Name and First Name, you need to hold the {Shift} key while clicking on the First Name column.

ultratree sorted by last and first name columns