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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to sort the Multi column tree view based on selected column index

Thread ID:

Created:

Updated:

Platform:

Replies:

122103 Feb 17,2016 10:16 AM UTC Feb 17,2016 11:36 AM UTC WinForms 1
loading
Tags: MultiColumnTreeView
gangadhar
Asked On February 17, 2016 10:16 AM UTC

Hi,

I want to sort the multi column tree view items based on column selection. Please suggest me how to do it.

The following is the code, which is sorting always with 0th column index. Hence i want sort based on column header selection (i.e. either 0,1,...).
if (treeNodesCollections[nodeIndex].HasNodes && treeNodesCollections[nodeIndex].Expanded)
{
      SortPatternExplorer(treeNodesCollections[nodeIndex], _treeViewSortOrder, _sortColumnIdx);
}

private void SortPatternExplorer(TreeNodeAdv treeNode, SortOrder order, int columnIdx)
{
            treeNode.SortOrder = order;
            treeNode.Sort();
}

In this above SortPatternExplorer taking sorting order but order applies based on 0th idex. instead of that i want to use the parameter "columnIdx".

Thanks & Regards
Gangadhar Yalaga

Senthil Kumaran Rajan [Syncfusion]
Replied On February 17, 2016 11:36 AM UTC

Hi Gangadhar,

Thanks for contacting Syncfusion Support.

The reported requirement can be achieved by passing the Root Node of the MultiColumnTreeView and ColumnIndex into the SortNodeByColumn function, Please make use of the below code example.

Code Example [C#]:

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

            }

}


We have prepared a sample and video for your reference and it can be downloaded from the below location.

Sample : http://www.syncfusion.com/downloads/support/forum/122103/MULTIC~1775032573.ZIP

Video : http://www.syncfusion.com/downloads/support/forum/122103/ze/MultiColumnSorting1678006044

Regards,
Senthil

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;