在 Windows Form DataGridView 控制項中排序資料
根據預設,使用者按一下文字方塊資料行的行首,即可在 DataGridView 控制項中排序資料。 在必要的情況下,只需修改特定資料行的 SortMode 屬性,就可以讓使用者依其他資料行型別來進行排序。 您也可以用程式設計方式,根據任何資料行或根據多個資料行來排序資料。
在本節中
Windows Form DataGridView 控制項中的資料行排序模式
描述控制項中用來排序資料的選項。HOW TO:設定 Windows Form DataGridView 控制項中的資料行排序模式
描述如何讓使用者根據預設無法排序的資料行來進行排序。HOW TO:自訂 Windows Form DataGridView 控制項的排序
描述如何以程式設計方式排序資料,以及如何使用 DataGridView.SortCompare 事件或實作 IComparer 介面來自訂排序。
參考
DataGridView
提供 DataGridView 控制項的參考文件。DataGridView.Sort
提供 Sort 方法的參考文件。DataGridViewColumn.SortMode
提供 SortMode 屬性的參考文件。DataGridViewColumnSortMode
提供 DataGridViewColumnSortMode 列舉型別的參考文件。
請參閱
概念
Windows Form DataGridView 控制項中的資料行型別