Home Forums WinForms controls Xceed Grid for WinForms sorted columns

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #16356 |

    Hi,
    Is there a method like GetSortedDataRows for Columns?
    Thanks in advance.

    Imported from legacy forums. Posted by troy@querytool.com (had 575 views)

    User (Old forums)
    Member
    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.

    e.g.:

    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)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.