Changing the TreeNode NodeFont to a bold font chops of text

  • Thread starter Jeroen-bart Engelen
  • Start date
J

Jeroen-bart Engelen

Hello,

I have a TreeView filled with nodes and then later on I wish to change
some node labels to a bold font. When I do this, the lenght of the
label gets longer, the boldness takes up more space, but instead of
showing al the text, the text gets cut off at a certain point. It seems
like the new bold text cannot be longer then the longest regular text.

Does anyone have an idea how to fix this?

Thanks,
Jeroen-bart Engelen
 
C

Claes Bergefall

From the docs for TreeNode.NodeFont:
"If the node font is larger than the Font property value set in the TreeView
control, the tree node label text is clipped."

Solution is to reverse your thinking. Set the entire tree to use a bold font
and then change the nodes you don't want bold.

/claes
 
J

Jeroen-bart Engelen

Claes said:
From the docs for TreeNode.NodeFont:
"If the node font is larger than the Font property value set in the TreeView
control, the tree node label text is clipped."

Solution is to reverse your thinking. Set the entire tree to use a bold font
and then change the nodes you don't want bold.

Thanks. I set it to bold and it fitted perfectly. Too perfect actually,
so I added an additional space at the end of the string when I set it
to bold. And now it even looks great! :)

Jeroen-bart Engelen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top