Home Forums WinForms controls Xceed Grid for WinForms sorted columns Reply To: sorted columns

User (Old forums)
Post count: 23064

If you want to know on which columns the grid is sorted, you can use GridControl.SortedColumns to get that list.

If you want to have a list of the columns in the order in which they appear in the grid, there is no property or method that will get you this.  However, you can use the VisibleIndex property on Column to get the index at which each column is displayed.


Column[] columns = new Column[ gridControl1.Columns.Count ];

foreach( Column col in gridControl1.Columns )


    columns.SetValue( col, col.VisibleIndex );


Then use the columns array as the sorted list of columns.

In fact, you could update your own list when columns are reordered, so the list is always up to date.  The VisibleIndexChanged event can be used for that, but note that other events may impact the list of Columns in the GridControl (e.g. ColumnAdded, ColumnRemoved, Column.VisibleChanged, etc…), so you would need to update your list when these events are triggered also.


Imported from legacy forums. Posted by André (had 1075 views)