RadTreeNodeComparer

6 posts, 0 answers
  1. Santiago
    Santiago avatar
    18 posts
    Member since:
    Nov 2007

    Posted 15 Nov 2007 Link to this post

    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.
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 16 Nov 2007 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 18 Mar 2011 Link to this post

    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
  5. Dipak
    Dipak avatar
    19 posts
    Member since:
    Oct 2008

    Posted 16 Nov 2012 Link to this post

    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
  6. Dipak
    Dipak avatar
    19 posts
    Member since:
    Oct 2008

    Posted 19 Nov 2012 Link to this post

    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
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 21 Nov 2012 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready