MultiColumnHeader 是一种通用类,例如可以与 TreeView 结合使用来创建多列树视图和列表视图。
它支持通过拖动来调整列宽的大小,并提供用于响应用户输入的实用回调。
请注意,用户可以使用 MultiColumnHeader 的上下文菜单隐藏列。
API 中使用的术语:参数名称 columnIndex
用于 MultiColumnHeaderState 对象中列数组的索引。参数名称 visibleColumnIndex
指的是 MultiColumnHeader 中显示的当前可见列索引。
canSort | 使用此属性控制是否为所有列启用排序。 |
height | 多列标题的可自定义高度。 |
sortedColumnIndex | 设置为主排序列的列的索引。此列显示标题文本上方的排序箭头。 |
state | 这是 MultiColumnHeader 的状态。 |
MultiColumnHeader | 构造函数。 |
GetCellRect | 使用 visibleColumnIndex 和 rowRect 参数计算列和行的单元格矩形。 |
GetColumn | 针对给定的列索引返回列数据。 |
GetColumnRect | 返回给定可见列索引的标题列矩形。 |
GetVisibleColumnIndex | 从列索引转换为可见列索引。 |
IsColumnVisible | 检查列当前在 MultiColumnHeader 中是否可见。 |
IsSortedAscending | 检查列的排序顺序状态。 |
OnGUI | 在给定矩形中渲染和处理 MultiColumnHeader 的输入。 |
Repaint | 请求重绘包含 MultiColumnHeader 的窗口。 |
ResizeToFit | 调整已启用自动调整大小的列的列宽,以使所有列适应 MultiColumnHeader 渲染矩形的宽度。 |
SetSortDirection | 更改给定列的排序方向。 |
SetSorting | 设置主排序列及其排序顺序。 |
SetSortingColumns | 设置多个排序列和相关的排序顺序。 |
AddColumnHeaderContextMenuItems | 重载此方法可展开单击标题区域时显示的默认上下文菜单项。 |
ColumnHeaderClicked | 重载可在单击列标题时自定义行为。 |
ColumnHeaderGUI | 重载可自定义单个列标题的 GUI。 |
OnSortingChanged | 在排序发生更改时调用并会分发 sortingChanged 事件。 |
OnVisibleColumnsChanged | 在可见列的数量更改时调用并会分发 visibleColumnsChanged 事件。 |
SortingButton | 提供列标题的按钮逻辑和排序箭头的渲染(如果可见)。 |
ToggleVisibility | 用于切换列可见性的方法。 |
sortingChanged | 订阅此事件可在排序发生变化时收到通知。 |
visibleColumnsChanged | 订阅此事件可在可见列的数量发生变化时收到通知。 |
HeaderCallback | 用于 MultiColumnHeader 中的事件的委托。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.