How to avoid part of node text not being visible in TreeView control in VB.NET (see picture)?

andreas_rafn
andreas_rafn used Ask the Experts™
on
I'm experiencing a weird visual behavior of Windows.Forms.TreeView controls that I haven't managed to avoid yet. Some of the text of root nodes are not showing. I have attached a screendump to show what I'm experiencing.
TreeViewAbnormality.PNG
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
have you overwritten the paint event?

can you reproduce this behavior in another project in which the treeview would have all the default values?

Author

Commented:
Haven't overwritten the Paint event, and couldn't reproduce the problem in a new project.
However I tried to change fonts back to defaults and that solved the problem. It is kind of annoying though, that one has to use stanmdard fonts for the TreeView to behave properly.

Author

Commented:
Intuitively it seems that the size of the root node is set to the size that would have been appropriate for a node with the default font (Microsoft Sans Serif, 8 pt, Regular). Is there any way to make sure the size of nodes follows the size/style of the chosen font??
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Most Valuable Expert 2012
Top Expert 2014

Commented:
Do you change font at runtime? I think changing it works at design time.
I change them at runtime. The problem is that the node collections are dynamic and cannot be created at design time, furthermore I have defined different fonts for different kinds of nodes, which seems to be the problem. Perhaps I just have to keep it simple.

Author

Commented:
I ended up simply using the default font for the TreeView control, as it, regretfully,  seems to be the only one working properly.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial