can i format a tree view text

6 posts, 0 answers
  1. Deepesh
    Deepesh avatar
    3 posts
    Member since:
    Nov 2010

    Posted 19 Nov 2010 Link to this post

    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 ?
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2010 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 19 Nov 2010 Link to this post

    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
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 19 Nov 2010 Link to this post

    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
  6. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 19 Nov 2010 Link to this post

    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.
  7. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 22 Mar 2011 Link to this post

    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

Back to Top
UI for WinForms is Visual Studio 2017 Ready