TreeView text is truncated if the font is changed from bold to normal

I have a WinForms TreeView. TreeView provides a summary of more detailed views, and one of the visual cues that I use is to make the text of the node bold or regular. The problem is that if you changed the font of the node from normal to bold, it fixed the text as if it was trying to put bold text in the space for plain text.

A little browser shows that the usual workaround is to set the TreeView font to bold and a selective set of nodes to regular.

This works better, but as soon as I change the node to normal, if I then change it to bold, it is cropped again. As I dynamically update my view, I am facing this problem.

Surprisingly, I could not find references to this problem in Stackoverflow, so I thought that I would do my bit and cry here. Does anyone know of a more thorough (but preferably not too redundant) workaround or solution to this problem?

I use C # 3 running on .Net 2.0, but if necessary I can use .Net 3.5.

[update]

No interlocutors, huh? This sucks. The best I have come up with so far is to add a load to the end of the line (to give it room for growth). It smells like so many levels (not least because it affects the scroll bars). I do not want me to go to a third-party control (or write my own), because it is only for the internal application for my development team. Given the change in metaphor, but it fits well.

+4
source share
3 answers

I ran into the same problem with VB.Net and the solution was as follows:

TreeView.BeginUpdate () '- Put your tree nodes here. TreeView.EndUpdate ()

+10
source

another solution was found: set the text after by changing the font instead of changing the font after adding the node with key and text properties

+3
source

I have the same problem (C #). My solution was: first set the treeView font to bold, and when some nodes do not have to be bold, change the font to normal:

if (conditionForRegularTreeNode) newNode.NodeFont = new Font(treeView.Font, FontStyle.Regular); 
0
source

Source: https://habr.com/ru/post/1300906/