This is a migrated thread and some comments may be shown as answers.

RadTreeNodeComparer

5 Answers 139 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Santiago
Top achievements
Rank 1
Santiago asked on 15 Nov 2007, 04:26 PM
Hi, I'm starting developing with Telerik WinForms and WebForms controls. First of all, I'm changin' a System TreeView for a Telerik TreeView. I wasn't hard, but, in my last Tree, I had one property for sort a custom level of the tree. I'd make a class NodeComparer that implements IComparer. Now, in Telerik, I read that this property is called RadTreeNodeComparer, and needs a class that implements IComparer<RadTreeNode>.

So, the code is like this:
    UIPresentationTree.RadTreeNodeComparer = new NodeSorter();

Nothing happens, and the tree don't sort anything. What's wrong?

thanks.

5 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 16 Nov 2007, 12:26 PM
Hello Santiago,

If you use this comparer in the FirstLook example in the QuickStart application, you will see that the nodes are sorted in reverse order.

public class ReverseSortComparer : IComparer<RadTreeNode> 
    #region IComparer<RadTreeNode> Members 
 
    public int Compare(RadTreeNode x, RadTreeNode y) 
    { 
        return y.Text.CompareTo(x.Text); 
    } 
    #endregion 


public Form1() 
    InitializeComponent(); 
    this.radComboBox1.SelectedIndex = 0; 
    this.radTreeView1.AllowMultiselect = true
 
    this.SelectedControl = this.radTreeView1; 
 
    this.checkImagesInFill.Text = "Highlight Node Text including its image"
 
    this.radTreeView1.RadTreeNodeComparer = new ReverseSortComparer(); 

I hope that helps. If you have any additional questions, please write us.

Kind regards,
Jordan
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Stefan
Telerik team
answered on 18 Mar 2011, 08:23 AM
Hello Santiago,

Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out.
For more information about this release, please refer to this blog post.
 
All the best,
Stefan
the Telerik team
0
Dipak
Top achievements
Rank 1
answered on 17 Nov 2012, 01:06 AM
I am using Q2 SP1 2012.  I want to sort a tree view where one node with Text " should display as Last node. I want to sort only ascending.I want to try above custom comparer but now that property is not available with this version.

Could you please guide me how can I achieve this?

Thanks
Dipak
0
Dipak
Top achievements
Rank 1
answered on 19 Nov 2012, 03:23 PM
I am using Q2 SP1 2012.  I want to sort a tree view where one node with Text " should display as Last node. I want to sort only ascending.I want to try above custom comparer but now that property is not available with this version.

Could you please guide me how can I achieve this?

Thanks
Dipak
0
Stefan
Telerik team
answered on 21 Nov 2012, 11:24 AM
Hi Dipak,

Thank you for writing.

Please refer to the following documentation article which explains how to use custom sort comparer with the latest version of the control: http://www.telerik.com/help/winforms/treeview-working-with-nodes-custom-sorting.html.

I hope this helps.
 
Regards,
Stefan
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
Treeview
Asked by
Santiago
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Stefan
Telerik team
Dipak
Top achievements
Rank 1
Share this question
or