按照网格列可见的相同顺序访问网格列

发布于 2024-07-21 06:26:44 字数 116 浏览 11 评论 0原文

我需要按照与网格中显示的顺序相同的顺序访问 infragistics ultragrid 的列。 如果我能够以与网格上可见的相同顺序获取列的索引,我就可以解决我的问题。 提前致谢。

拉利特

I need to access columns of infragistics ultragrid in same sequence in which they are being displayed in grid. If i can get the index of column in same sequence as they are visible on grid, i can fix my issues.
Thanks in advance.

Lalit

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

咆哮 2024-07-28 06:26:44
UltraGridColumn column = this.ultraGrid1.DisplayLayout.Bands[0].Columns[0];

Debug.WriteLine( "Columns in visible order: ");

       // Get the first visible column by passing in VisibleRelation.First.
       column = column.GetRelatedVisibleColumn( VisibleRelation.First );

       while ( null != column )
       {
           Debug.WriteLine( "   " + column.Key );

           // Get the next visible column by passing in VisibleRelation.Next.
           column = column.GetRelatedVisibleColumn( VisibleRelation.Next );
       }

UltraGridColumn column = this.ultraGrid1.DisplayLayout.Bands[0].Columns[0];

Debug.WriteLine( "Columns in visible order: ");

       // Get the first visible column by passing in VisibleRelation.First.
       column = column.GetRelatedVisibleColumn( VisibleRelation.First );

       while ( null != column )
       {
           Debug.WriteLine( "   " + column.Key );

           // Get the next visible column by passing in VisibleRelation.Next.
           column = column.GetRelatedVisibleColumn( VisibleRelation.Next );
       }

http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v8.2~Infragistics.Win.UltraWinGrid.UltraGridColumn~GetRelatedVisibleColumn.html

滿滿的愛 2024-07-28 06:26:44

我想您可以尝试处理顺序更改时触发的事件并跟踪所有更改,但这似乎要求出现微妙的错误。

我考虑循环遍历所有列并尝试使用一些属性会告诉我它们当前的位置(也许是 TabOrder?)并使用它来编译列的有序列表。 我想您可能必须使用 Column.GetRelatedVisibleColumn() 方法循环遍历每个列。

我还没有真正实施它,因为我还有其他更优先的问题,但这可能是我最终要走的路。

I suppose you could try to handle the event that is fired when the order is changed and keep track of all the changes, but this seems like it is asking for subtle bugs to creep in.

I considered looping through all the columns and trying to use some property that would tell me their current position (maybe the TabOrder?) and use that to compile an inorder list of the columns. I guess you might have to loop through each colum using the Column.GetRelatedVisibleColumn() method.

I have not actually implemented it yet as I have other higher priority issues but that may be the road I end up going down.

自演自醉 2024-07-28 06:26:44

这是一个老问题,但我最近遇到了同样的问题并以这种方式解决了它:

var selectedCells = this.Selected.Cells;

List<int> columns = new List<int>();

foreach (var cell in selectedCells)
        {
            if (!columns.Contains(cell.Column.Index))
                columns.Add(cell.Column.Index);
        }

columns.Sort((x, y) => this.DisplayLayout.Rows.Band.Columns[x].Header.VisiblePosition.CompareTo(this.DisplayLayout.Rows.Band.Columns[y].Header.VisiblePosition));

然后您可以使用 columns 按显示顺序访问列。

This is an old question, but I recently had same issue and solved it this way:

var selectedCells = this.Selected.Cells;

List<int> columns = new List<int>();

foreach (var cell in selectedCells)
        {
            if (!columns.Contains(cell.Column.Index))
                columns.Add(cell.Column.Index);
        }

columns.Sort((x, y) => this.DisplayLayout.Rows.Band.Columns[x].Header.VisiblePosition.CompareTo(this.DisplayLayout.Rows.Band.Columns[y].Header.VisiblePosition));

You can then use columns to access columns in order they are shown.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文