How to hide column of devexpress XtraGrid

31,999

Solution 1

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

Solution 2

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.

Share:
31,999
Vyasdev Meledath
Author by

Vyasdev Meledath

#SOreadytohelp

Updated on July 09, 2022

Comments

  • Vyasdev Meledath
    Vyasdev Meledath almost 2 years

    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