How to sort columns in Infragistics Wingrid


This code shows how WinGrid allows the user to sort on both single and multiple columns by clicking on the column headers.

This code demonstrates how WinGrid allows the user to sort on both single and multiple columns by clicking on the column headers. The UltraWinGrid allows user to sort by setting the .HeaderClickAction property to either .SortSingle or .SortMulti.

Below are the steps to achieve the same

1. Adding using/imports directives
VB:


Imports Infragistics.Win.UltraWinGrid

C#:

using Infragistics.Win.UltraWinGrid;


2. The InitializeLayout event of UltraGrid sets the default HeaderClickAction for all bands and all columns

VB:

Private Sub UGSort_InitializeLayout(ByVal sender As Object, _
ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) _
Handles UGSort.InitializeLayout
e.Layout.Override.HeaderClickAction = HeaderClickAction.SortSingle
End Sub


C#:

private void UGSort_InitializeLayout(object sender,
Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
e.Layout.Override.HeaderClickAction = HeaderClickAction.SortSingle;
}


3. The code in the Button Click event instructs the UltraWinGrid to sort on band 1 column 2 in Descending order

Visual Basic:

Private Sub btnSortBand1Column2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnSortBand1Column3.Click
Me.UltraGrid1.DisplayLayout.Bands(1).Columns(2).SortIndicator = _
SortIndicator.Descending
End Sub


C#:

private void btnSortBand1Column2_Click(object sender, EventArgs e)
{
this.ultraGrid1.DisplayLayout.Bands[1].Columns[2].SortIndicator =
SortIndicator.Descending;
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: