假设我们有一个UltraGrid。 我如何首先按编程方式对其进行排序,然后是B,然后是B,然后是C.
谢谢!
答案 0 :(得分:23)
您只需设置排序指标(顺序很重要),代码取自上面的链接:
UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0];
// Sort the rows by Country and City fields. Notice the order in which these columns
// are set. We want to sort by Country and then sort by City and in order to do that
// we have to set the SortIndicator property in the right order.
band.Columns["Country"].SortIndicator = SortIndicator.Ascending;
band.Columns["City"].SortIndicator = SortIndicator.Ascending;
// You can also sort (as well as group rows by) columns by using SortedColumns
// property off the band.
band.SortedColumns.Add( "ContactName", false, false );
答案 1 :(得分:2)
如果您还想通过ContactName自动分组,可以为您执行此操作:
band.SortedColumns.Add( "ContactName", false, true);
注意使用true作为最后一个参数