如何隐藏devexpress XtraGrid的列
大家好, 我在 C#.NET 应用程序中使用 devexpress XtraGrid。在运行时,我想隐藏 XtraGrid 的 1 列并在代码隐藏页面中访问该列。请帮助访问 超网格。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
好的。我这样做是为了无限期地隐藏所有 xtraGrid 列,以便我可以选择可以显示的少数列(使可见为 true)。
希望有帮助。
Ok. I did this to indefinitely hide ALL my xtraGrid columns so I can select the few I can show (make visible true).
Hope it helps.
试试这个:
ColumnName.Visible=False;
Try this:
ColumnName.Visible=False;
您应该使用
View.Columns[someFieldName].Visible
属性来隐藏/显示列。另请参阅以下主题:http://documentation.devexpress.com/#WindowsForms/CustomDocument753< /a>
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
要向用户隐藏列,请将 columnsvisible 属性设置为 False,如上所述。
但是,这会将隐藏列放入 SelectColumn 菜单中,用户可以在运行时访问该菜单。
右键单击网格标题 ->单击选择列->从小窗口选择隐藏列->将其拖到网格中。
在这种情况下,您的隐藏列将可供用户使用。有两种可能的解决方案可以避免上述情况:
除了设置 Column 的可见属性之外,还将 OptionColumn.AllowShowHide 设置为 False。这将确保该列不会在列选择窗口中弹出。
仅当您绝对不想授予用户更改网格布局的权利时,才应使用其他解决方案。这可以通过将 GridView 的属性 - OptionMenu->EnableColumnMenu 设置为 False 来完成。
但是,设置后,此用户将被限制使用所有其他布局选项,例如分组、过滤器、搜索等。
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:
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.
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.