Search code examples
c#devexpressxtragrid

DevExpress XtraGrid: Make column visible to user


I have a grid with lots of columns (ca. 100). I've written a column selector context menu (which has each letter of the alphabet and then as subitems all the columns beginning with that letter).

When the user clicks in the context menu I want to make the column they have chosen visible to the user (preferably in the middle of the visible grid). I don't want to actually mess with the column order, I just want to make sure a column is visible to the user.

Any ideas?


Solution

  • This can be done using the following approach:

    1) set the column's Visible property to true.

    2) if you want this column to be in the middle of the grid, set its VisibleIndex property to gridView.VisibleColumnsCount / 2;

    3) call the GridView's MakeColumnVisible method to make this column visible to the end user.