Version: 2021.3
LanguageEnglish
  • C#

MultiColumnHeader

class in UnityEditor.IMGUI.Controls

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

The MultiColumnHeader is a general purpose class that e.g can be used with the TreeView to create multi-column tree views and list views.

It supports resizing of columns widths by dragging and provides useful callbacks for reacting to user input. Note that columns can be hidden by the user using the context menu of the MultiColumnHeader.

Terminology used in the API: The parameter name columnIndex is used for indices into the columns array in the MultiColumnHeaderState object. While the parameter name visibleColumnIndex refers to the currently visible column index shown in the MultiColumnHeader.

Properties

allowDraggingColumnsToReorderUse this property to control whether the user can drag and drop columns to re-order them.
canSortUse this property to control whether sorting is enabled for all the columns.
currentColumnIndexThe index of the column that is currently being handled during an event. This property can be used for column specific handling when overriding AddColumnHeaderContextMenuItems
heightCustomizable height of the multi column header.
sortedColumnIndexThe index of the column that is set to be the primary sorting column. This is the column that shows the sorting arrow above the header text.
stateThis is the state of the MultiColumnHeader.

Constructors

MultiColumnHeaderConstructor.

Public Methods

GetCellRectCalculates a cell rect for a column and row using the visibleColumnIndex and rowRect parameters.
GetColumnReturns the column data for a given column index.
GetColumnRectReturns the header column Rect for a given visible column index.
GetVisibleColumnIndexConvert from column index to visible column index.
IsColumnVisibleCheck if a column is currently visible in the MultiColumnHeader.
IsSortedAscendingCheck the sorting order state for a column.
OnGUIRender and handle input for the MultiColumnHeader at the given rect.
RepaintRequests the window which contains the MultiColumnHeader to repaint.
ResizeToFitResizes the column widths of the columns that have auto-resize enabled to make all the columns fit to the width of the MultiColumnHeader render rect.
SetSortDirectionChange sort direction for a given column.
SetSortingSets the primary sorting column and its sorting order.
SetSortingColumnsSets multiple sorting columns and the associated sorting orders.

Protected Methods

AddColumnHeaderContextMenuItemsOverride this method to extend the default context menu items shown when context clicking the header area.
ColumnHeaderClickedOverride to customize the behavior when clicking a column header.
ColumnHeaderGUIOverride to customize the GUI of a single column header.
OnSortingChangedCalled when sorting changes and dispatches the sortingChanged event.
OnVisibleColumnsChangedCalled when the number of visible column changes and dispatches the visibleColumnsChanged event.
SortingButtonProvides the button logic for a column header and the rendering of the sorting arrow (if visible).
ToggleVisibilityMethod for toggling the visibility of a column.

Events

columnSettingsChangedEvent raised when any settings from a column has changed (for example, a column width was resized).
columnsSwappedEvent raised when the user switches the order of two columns.
sortingChangedSubscribe to this event to get notified when sorting has changed.
visibleColumnsChangedSubscribe to this event to get notified when the number of visible columns has changed.

Delegates

HeaderCallbackDelegate used for events from the MultiColumnHeader.