假设我们有一个 UltraGrid。如何以编程方式首先按 A 列、B 列、C 列对其进行排序。
谢谢!
您可以只设置排序指示器(顺序很重要),代码取自上面的链接:
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 );
关于第二种方法的更多信息可以在这里找到:http: //help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v8.2~Infragistics.Win.UltraWinGrid .SortedColumnsCollection~Add.html
如果您还想按 ContactName 自动分组,可以这样做:
band.SortedColumns.Add( "ContactName", false, true);
注意使用 true 作为最后一个参数