'宣言 Public Property SortIndicator As SortIndicator
public SortIndicator SortIndicator {get; set;}
UltraGrid では、コードを追加せずに列の内容を自動的に並べ替えることができます。UltraGrid は列データの自動並べ替え機能と共に、独自の並べ替え動作をコードで実装するためのツールも提供します。
列ヘッダーは列のヘッダーに並べ替えインジケーターを表示できます。HeaderClickAction プロパティがHeaderClickAction.SortSingle または HeaderClickAction.SortMulti に設定されている場合にヘッダーをクリックすると、 SortIndicator プロパティに列の並べ替え順序が設定され、その列が並べ替え列用の特別な Columns コレクションに追加されます。自動並べ替えが無効な場合は、SortedCols によってアクセス可能な Columns コレクションに列が追加されると共に、BeforeSortChange イベントと AfterSortChange イベントが発生します。このイベントでコレクションの内容を調べ、各列の SortIndicator プロパティの値をチェックして、並べ替えを実行できます。
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinGrid Private Sub Button22_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button22.Click Dim band As UltraGridBand = Me.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 ' To sort multi-column using SortedColumns property ' This enables multi-column sorting this.ultraGrid1.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti ' It is good practice to clear the sorted columns collection band.SortedColumns.Clear() ' You can sort (as well as group rows by) columns by using SortedColumns ' property off the band band.SortedColumns.Add("ContactName", False, False) End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Diagnostics; private void button22_Click(object sender, System.EventArgs e) { 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; // To sort multi-column using SortedColumns property // This enables multi-column sorting this.ultraGrid1.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti; // It is good practice to clear the sorted columns collection and.SortedColumns.Clear(); // You can sort (as well as group rows by) columns by using SortedColumns // property off the band band.SortedColumns.Add( "ContactName", false, false ); }