Multi-column views enable the display of multiple columns in using tree or list view controls. They are instantiated differently in the UI Toolkit and IMGUI frameworks.
Multi-column views are not in the UI Builder library as of 2022.1.
To create these controls;
1. First add multi-column viewcontrols to UXML,
2. define the column data in C# and reference this object,
3. and customize using Column properties.
To create a list or tree view with multiple columns, first create a MultiColumnListView or MultiColumnTreeView UI control, and define the number of columns and column titles in a UXML file.
Examples below have a column with a list of planets and toggles that indicate whether the planet is populated:
Add the following code in a .uxml file:
Add the following code in a .uxml file:
Define where to get data for each column in a C# script and reference the UXML file to this script.
Column class properties are used to define how a user interacts with a column in a multi-column view, and how its data and the data of each cell in this column are represented.
Multi-column views are the standard tree view control configured with MultiColumnHeader and MultiColumnHeaderState classes.
1. Create some columns using MultiColumnHeaderState and set the column properties.
2. Create a Column State object with the created columns
3. Create a MultiColumnHeader object with the state
4. Create a TreeView with the MultiColumnHeader object.
To create a list view follow the same steps above for the multi-column tree view but ensure all view items are located under the root to make it a listview (so that there are no hierarchical relationships).