Crono Posted December 10, 2002 Posted December 10, 2002 I'm populating a TreeView control at run-time and I want my first-level nodes to be in bold text. When I change font via TreeNode.NodeFont, the node isn't resized to fit with the new text size and it appears only partialy. I know I could change the width of the node, but it won't fit to the text. Isn't there any other way? Quote
*Gurus* divil Posted December 10, 2002 *Gurus* Posted December 10, 2002 This is a known problem and has to do with GDI+ and clipping. The only solution that works is to change the Font of the treeview itself to bold, and then each node added that is NOT bold changed to reflect that as you add it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Crono Posted December 10, 2002 Author Posted December 10, 2002 You're right, it looks like it's the only way out... Thank you! :) Quote
willemf Posted August 20, 2008 Posted August 20, 2008 You should not have to reverse the font for the tree as suggested.... I got it to work by first setting the font, then setting the text - something like the code snippet below: public void SetNodeFont(TreeNode node, Font font) { // First set the new font for the node. node.NodeFont = font; // Set the text again - forces the bounding box // of the node to be set around the text using // the new font. node.Text = node.Text; } Rgds, Willem Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.