Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide column of devexpress XtraGrid

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

like image 592
Vyasdev Meledath Avatar asked Sep 01 '10 06:09

Vyasdev Meledath


2 Answers

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.

like image 64
IFlyHigh Avatar answered Sep 27 '22 21:09

IFlyHigh


You should use the View.Columns[someFieldName].Visible property to hide / show a column. Please also refer to the following topic:

http://documentation.devexpress.com/#WindowsForms/CustomDocument753

like image 26
DevExpress Team Avatar answered Sep 27 '22 22:09

DevExpress Team