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
765
Highlight part of node's text
posted

I'm implementing a search and I would like to go through and "highlight" where that search word appears.  I'm fine with just changing the color or bolden the searched text but I can't figure out how to do this.  I found another thread where you talked about this but it was in relation to a grid and wasn't sure if there is something different that I have to do for a tree.  I tried using span tags but they show up in the node's text, instead of being implemented as a tag. Here is what I have:

 //Highlight the search term in each node
            foreach (UltraTreeNode node in this.ultraTree1.Nodes)
            {
                string replacement = String.Format("<span style=\"background-color:Yellow;\">{0}</span>", searchText);
                string val = node.Text.ToString();
                val = val.Replace(searchText, replacement);
                node.Text = val;
            }

Parents
No Data
Reply
  • 69832
    Verified Answer
    Offline posted

    I am speculating a little here, but it sounds like at some point someone recommended that you use a FormattedTextEditor to get partially bolded text in a tree node. If that is that case, what you need to do is assign an Infragistics.Win.FormattedLinkLabel.FormattedLinkEditor to the UltraTree.Override.Editor property, and then assign the formatted text to the node with the appropriate characters bolded after your search is performed.

Children