UltraTree , SortComparer help!

Joined
Sep 15, 2008
Messages
2
Reaction score
0
I have a Ultra Tree that i have created an IComparer Class to sort the tree, but it isn't sorting the tree. I am probably doing somthing wrong, can anyone help me ?

this is what i have

This is the constructor
public ReportsViewer2()
{
InitializeComponent();
_openedFilesHash =
newHashtable();
nodeTooltip =
new Infragistics.Win.ToolTip ( ultraTree1 );
nodeTooltip.InitialDelay = 0;
ultraTree1.Nodes.Override.SortComparer =
new ITreeNodeSortOrderComparer();
ultraTree1.Nodes.Override.Sort =
SortType.Ascending;
}

and this is the IComparer class:

public class ITreeNodeSortOrderComparer :IComparer
{
publicint Compare(Object x, Object y)
{
int retVal = -1;
if (x isUltraTreeNode && y isUltraTreeNode)
{
retVal =
string.Compare(((UltraTreeNode)x).Text, ((UltraTreeNode)y).Text);
}
else
{
throw (newException("Can not do a UltraTreeNode Compare on non UltraTreeNode objects."));
}
return retVal;
}

}
 
Joined
Oct 7, 2009
Messages
1
Reaction score
0
its been a while since you posted but I figured I would post since I used your code and got it working.

For me the trick was setting

ultTree.Override.Sort = SortType.Ascending;

the default is SortType.None, which causes the sortcomparer to never fire off

oh also calling ultTree.RefreshSort() when you want the sorting to happen... GL!
 
Joined
Sep 15, 2008
Messages
2
Reaction score
0
I'm glad you used the code. I think i had solved the issue, not sure what i did.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top