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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to sort WinForms MultiColumnTreeView based on the ColumnIndex?

Platform: WinForms |
Control: MultiColumnTreeView


In MultiColumnTreeView, Nodes can be sorted in ascending or descending order by using its function named Sort.


//Pass the column index and root of the MultiColumnTreeView
SortNodesByColumn(this.multiColumnTreeView1.Root, 1);
//To Sort the MultiColumnTreeView based on the Column index
private void SortNodesByColumn(TreeNodeAdv ParentNode, int ColumnIndex)
     foreach (TreeNodeAdv node in ParentNode.Nodes)
        if (node.HasNodes)
           SortNodesByColumn(node, 1);
        node.Nodes.Sort(new SortBySubItems(this.multiColumnTreeView1, ColumnIndex,this.CheckBox1.Checked));



'Pass the column index and root of the MultiColumnTreeView
Me.multiColumnTreeView1.Nodes.AddRange(New TreeNodeAdv(){root1,root2,root3,root4})
'To Sort the MultiColumnTreeView based on the Column index
Private Sub SortNodesByColumn(ByVal ParentNode As TreeNodeAdv, ByVal ColumnIndex As Integer)
   For Each node As TreeNodeAdv In ParentNode.Nodes
     If node.HasNodes Then
  SortNodesByColumn(node, 1)
     End If
     node.Nodes.Sort(New SortBySubItems(Me.multiColumnTreeView1, ColumnIndex,       Me.CheckBox1.Checked))
   Next node   
End Sub

    Sort using column index and root node          

Figure 1. MultiColumnTreeView sorted using Column Index and root node


C#: SortMultiColumnTreeView C#

VB: SortMultiColumnTreeView VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile