How to hide column of devexpress XtraGrid

Vyasdev Meledath picture Vyasdev Meledath · Sep 1, 2010 · Viewed 29.5k times · Source

Hai all, Am using devexpress XtraGrid in C#.NET application.On run time i want to hide 1 column of XtraGrid and access that column in code behind page.And please help to access rows and columns of XtraGrid.

Thank You

Answer

IFlyHigh picture IFlyHigh · Apr 24, 2014

To hide a column from user set columns visible property to False as mentioned above.

However this puts the hidden column in SelectColumn Menu which user can access at run time.

Right Click Grid Header -> Click Select Columns -> Choose hidden column from small window -> Drag it to the Grid.

In this case your hidden columns will be available to user. There are two possible solutions to avoid above Situation:

  1. In Addition to setting visible property of Column also set OptionColumn.AllowShowHide to False. This will make sure that this column will not Pop up in column select window.

  2. Other solution should be used only when you want to give absolutely no right to the user for changing the layout of the grid. This can be done by Setting GridView's property - OptionMenu->EnableColumnMenu to False. However after setting this user will be restricted from all other layout Options also like Groupping, filter, search etc.