Node text with different fonts or colors

2 posts, 1 answers
  1. Karl
    Karl avatar
    35 posts
    Member since:
    Dec 2013

    Posted 12 Oct Link to this post

    I would like to decorate the text of my nodes at runtime with a label showing the child count in a different color and font.  How can I achieve this?

     

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 13 Oct Link to this post

    Hello Karl,

    Thank you for writing.

    You can use the NodeFormatting event and add HTML styled text:
    private void RadTreeView1_NodeFormatting(object sender, Telerik.WinControls.UI.TreeNodeFormattingEventArgs e)
    {
        e.NodeElement.ContentElement.Text = string.Format("<html>{0}  <span style=\"color: red\">Child Nodes {1}</span>", e.Node.Text, e.Node.Nodes.Count);
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top