在 DevExpress 控件中,BandedGridColumn 的 属性 VisibleIndex 不起作用

In DevExpress Controls, the Property VisibleIndex of BandedGridColumn does not work

我编写了以下代码来隐藏特定列:

(_view as BandedGridView).Columns[j].VisibleIndex = -1;

这有效

但是,我想通过以下代码更改列的顺序:

(_view as BandedGridView).Columns[j].VisibleIndex = i;

但这不起作用

寻求帮助,谢谢

根据 documentation,将值分配给 VisibleIndex 属性 大于 -1 尝试移动列无效:

Setting the VisibleIndex property to -1 hides the column. In this case, the column header is displayed within the Customization Form (provided that the column's OptionsColumn.ShowInCustomizationForm option is enabled).

Note that assigning values greater than -1 has no effect. To change the column's position among visible columns in Banded Grid Views, use the GridBandColumnCollection.MoveTo method.

假设您在设计器中有一个 GridBand:

private DevExpress.XtraGrid.Views.BandedGrid.GridBand GridBand1;

您可以使用 MoveTo 方法来更改列位置:

GridBand1.Columns.MoveTo(i, [BandedGridColumn]);

注意:[BandedGridColumn] 指的是 DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn 在设计器中声明的对象名称。

类似问题:

Strange Behavior when setting VisibleIndex in BandedGridView after user customization