3

我有一个使用 bindingSource 的 Infragistics UltraGrid。

如果我在绑定列表中添加一个新对象,它会在网格底部添加一行,如果没有用户定义的排序,这很好。

问题是如果用户单击列标题对网格进行排序,有没有办法让新行以正确的排序顺序出现,而不是总是在底部?

在每次插入时重新排序所有行太昂贵了。

4

1 回答 1

8

似乎有点贫民窟。Infragistics 支持还表明 RefreshSortPosition() 方法是唯一的选择。

// Add to binding list which will trigger a row to be added to the bound ultragrid.
this.bindingList.Add(new Person("Smith", "John"));

// Get length since we know this will always be added to the end
int length = this.ultraGrid.Rows.All.Length;

// Get it to sort
this.ultraGrid.Rows[length - 1].RefreshSortPosition();

为了提高效率,您总是可以通过禁用重绘等来变得聪明,然后在一批订单之后对一堆行调用刷新等......

希望有帮助。我在谷歌搜索这个问题时运气不佳。

于 2009-03-26T19:40:19.640 回答