简体   繁体   English

DevExpress XtraGrid:使列对用户可见

[英]DevExpress XtraGrid: Make column visible to user

I have a grid with lots of columns (ca. 100). 我有一个带有很多列的网格(大约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? 有任何想法吗?

This can be done using the following approach: 可以使用以下方法完成此操作:

1) set the column's Visible property to true. 1)将列的Visible属性设置为true。

2) if you want this column to be in the middle of the grid, set its VisibleIndex property to gridView.VisibleColumnsCount / 2; 2)如果您希望此列位于网格的中间,请将其VisibleIndex属性设置为gridView.VisibleColumnsCount / 2;

3) call the GridView's MakeColumnVisible method to make this column visible to the end user. 3)调用GridView的MakeColumnVisible方法使该列对最终用户可见。

Use the GridColumn.VisibleIndex property to change the order in which columns are displayed. 使用GridColumn.VisibleIndex属性更改列的显示顺序。

VisibleIndex = -1 hides a column IIRC. VisibleIndex = -1隐藏一列IIRC。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM