如何以编程方式按多列对 UltraGrid 进行排序?

发布于 2024-10-16 05:44:13 字数 77 浏览 9 评论 0原文

假设我们有一个 UltraGrid。 我怎样才能以编程方式首先按 A 列排序,然后按 B 列,然后按 C 列排序。

谢谢!

Say we have an UltraGrid.
How can I sort it programmatically first by column A, then B, then C.

Thanks!

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

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

发布评论

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

评论(2

葬花如无物 2024-10-23 05:44:13

此处的文档:

您可以只设置排序指示器(顺序很重要),代码取自上面的链接

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 );

有关第二种方法的更多信息可以在此处找到:

Documentation here:
http://help.infragistics.com/Help/Doc/WinForms/2011.2/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v11.2~Infragistics.Win.UltraWinGrid.UltraGridBand~SortedColumns.html

You can just set the sort indicator (order is important), code taken from above link:

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 );

More information on the second method can be found here:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/Infragistics2.Win.UltraWinGrid.v8.2~Infragistics.Win.UltraWinGrid.SortedColumnsCollection~Add.html

帅的被狗咬 2024-10-23 05:44:13

如果您还想按 ContactName 自动分组,这可能适合您:

band.SortedColumns.Add( "ContactName", false, true);

注意使用 true 作为最后一个参数

If you also wanted to automatically group by ContactName this may do it for you:

band.SortedColumns.Add( "ContactName", false, true);

Notice usage of true as the last parameter

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