We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How do I perform multicolumn sorting in a GridDataBoundGrid?

 

In a GridDataBoundGrid, you can sort a columns by either clicking or double-clicking the column headers. By default it supports sort a single column. In this section, we provide a sample that contains a SortHelper class that you can include in any projects to facilitate multicolumn sorting. This helper class requires your datasource to be a DataTable (or DataView or DataSet+TableName).

User can sort columns by clicking the header cells just as before, and also if the user perform ctl+clicks, the sorting will retain current sort order for any column that is already sorted. In this manner, the user can do multicolumn sorts. There is also an API call in the SortHelper class that allows you to programmatically sort multiple columns from code.

C#

private GridMultiColSortHelper sortHelper = null;

private void Form1_Load(object sender, System.EventArgs e)

{

//create and wire the sorthelper object

sortHelper = new GridMultiColSortHelper();

sortHelper.WireGrid(this.gridDataBoundGrid1, true); //true indicate teh helper will resize to fit column headers

}

VB

Private sortHelper As GridMultiColSortHelper = Nothing

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

'create and wire the sorthelper object

sortHelper = New GridMultiColSortHelper

sortHelper.WireGrid(Me.gridDataBoundGrid1, True) 'true indicate teh helper will resize to fit column headers

End Sub 'Form1_Load

Here is the link with both CS and VB samples: http://websamples.syncfusion.com/samples/kb/grid.windows/GDBGMultiSort/main.htm

Article ID: Published Date: Last Revised Date: Platform: Control:
485 04/30/2011 07/10/2014 Windows Forms GridDataBoundGrid(Classic)
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon