Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
UltraTree search problems
posted

Hello all,

I'm attempting to use a textBox to allow the user to "search" for a node (Report in our software). I've created a text changed event on the textBox so that when user types a letter it will search through the nodes looking for matching and only show those matches. 

What works:

user can type and get the results to narrow down

What doesn't:

If a user backspaces, these results aren't repopulating the matching strings. 

This is the same case if a user misspells an item. 

Something that I've done is if the user removes all text then I essentially rebuild the tree which is inefficiency. It seems that once I ExpandAll on a UltraTreeChildNode, there is no way to restore the original tree with out rebuilding it. 

private void searchQueriesTxtBox_TextChanged(object sender, EventArgs e)
        {
            string testString = searchQueriesTxtBox.Text.ToLower();
            TreeNodesCollection collection = utvDbQuery.Nodes;
            if (searchQueriesTxtBox.Text.Length == 0)
                DbQueryListBuild();
            if (searchQueriesTxtBox.Text.Length > 0)
            {
                foreach (UltraTreeNode childNode in utvDbQuery.Nodes)
                {
                    if (childNode.Text.ToLower().Contains(testString))
                    {
                        childNode.ExpandAll();
                    }
                    else
                    {
                        childNode.Visible = false;
                    }
                }
            }
        }
Parents
  • 12480
    Offline posted

    Hi Timothy,

    Thank you for sending your code. I am working now to incorporate it into a sample application in order to see whether I am able to reproduce the behavior you are describing.

    Please let me know if you have any questions for me.

Reply Children