Node text with different fonts or colors

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

    Posted 12 Oct 2016 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 avatar
    2563 posts

    Posted 13 Oct 2016 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.

    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.
Back to Top