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

Node text with different fonts or colors

1 Answer 198 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Karl B
Top achievements
Rank 1
Karl B asked on 12 Oct 2016, 08:19 PM

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?

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 13 Oct 2016, 02:00 PM
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.
Tags
Treeview
Asked by
Karl B
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or