How to Add Sort Icons in Windows Forms Grid Control
18 Nov 20181 minute to read
Add GridSortColumnHeaderCellModel to the GridControl’s CellModels collection to include SortColumn HeaderCell. Then assign this as CellType and set tag property to either ListSortDirection.Ascending or ListSortDirection.Descending to show the up and down arrow mark.
//Registers GridSortColumnHeaderCellModel to the GridModel.
this.gridControl1.CellModels.Add("SortHeader", new GridSortColumnHeaderCellModel(this.gridControl1.Model));
//Sets new cell type to a column header cell.
this.gridControl1[0,1].CellType = "SortHeader";
//Specifies the sort direction in the Tag property of the column header.
this.gridControl1[0,1].Tag = ListSortDirection.Ascending;'Registers GridSortColumnHeaderCellModel to the GridModel.
Me.GridControl1.CellModels.Add("SortHeader", New GridSortColumnHeaderCellModel(Me.GridControl1.Model))
'Sets new cell type to a column header cell.
Me.GridControl1(0, 1).CellType = "SortHeader"
'Specifies the sort direction in the Tag property of the column header.
Me.GridControl1(0, 1).Tag = ListSortDirection.AscendingThis will only display the sort indicator; it does not actually do any sorting.