This is a migrated thread and some comments may be shown as answers.

can i format a tree view text

5 Answers 444 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Deepesh
Top achievements
Rank 1
Deepesh asked on 19 Nov 2010, 08:54 AM
Team,

can i format a tree view text like

my tree view node is like
---My String (1234)

so please tell me can i bold this 1234 if yes then please suggest How ?

5 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 19 Nov 2010, 09:23 AM
Hello,

Sorry, you cannot bold just part of the text, you can just change the font for the entire text.

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 19 Nov 2010, 12:04 PM
Hello Deepesh,

You can format part of the text in a RadTreeView Node by using HTML-Like formatting.
For exmaple:

Me.RadTreeView1.Nodes.Add("<html><strike>Node Strike</html>")
Me.RadTreeView1.Nodes.Add("<html><color= Red>Node Red</html>")
Me.RadTreeView1.Nodes.Add("<html><strong>Node Bold</strong> and not so bold</html>")

you can view all the tags for HTML-Like formatting at this link

hope that helps, but let me know if you have any other questions.
Richard
0
Emanuel Varga
Top achievements
Rank 1
answered on 19 Nov 2010, 01:27 PM
Hello again,

Yes, sorry, i forgot about the markup editor for the tree... my bad (thank you Richard)

Other than that you can use this code to achieve the desired effect.
    FormatTreeNodes(radTreeView1.Nodes);
 
private void FormatTreeNodes(RadTreeNodeCollection levelNodes)
{
    foreach (RadTreeNode node in levelNodes)
    {
        if (node.Text.Contains('('))
        {
            var text = new StringBuilder(node.Text);
            text = text.Replace("(", "(<strong>");
            text = text.Replace(")", "</strong>)");
            node.Text = ("<html>" + text + "</html>").ToString();
        }
 
        FormatTreeNodes(node.Nodes);
    }
}

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Ivan Todorov
Telerik team
answered on 19 Nov 2010, 06:18 PM
Hello,

Thank you all for writing.

Deepesh, I hope that the posts of Richard and Emanuel answered your question. Please let us know if you need further help.

Richard, Emanuel, thank you for the assistance!

Best wishes,
Ivan Todorov
the Telerik team
Get started with RadControls for WinForms with numerous videos and detailed documentation.
0
Stefan
Telerik team
answered on 22 Mar 2011, 03:16 PM
Hello guys,

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 on our latest release refer to this blog post.

All the best,
Stefan
the Telerik team

Tags
Treeview
Asked by
Deepesh
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Ivan Todorov
Telerik team
Stefan
Telerik team
Share this question
or