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;
            }