473,395 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

NodeFont change results in truncated text (bug in .NET Framework)

Seems that there's a bug in the TreeNode object. When you change the font,
it does not readjust its size appropriately.

The following code shows the boldface text truncated with everything after
"W" removed.

private void Form1_Load(object sender, System.EventArgs e) {
TreeNode newNode = new TreeNode("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
treeView1.Nodes.Add(newNode);
newNode = new TreeNode("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
newNode.NodeFont = new Font(this.Font, FontStyle.Bold);
treeView2.Nodes.Add(newNode);
}

What I want to know is, how do I work around this? I need some of the nodes
to be in bold!

Thanks,
Jon
Nov 15 '05 #1
2 4440
Hi Jon,

I agree this *looks* as a bug, but I believe this behavior is documented in
MSDN that warns the text *will* be truncated if the node font is larger than
the tree font. The trick I've used was to set the base tree font to bold,
and reset the boldness flag on all nodes that didn't need to be rendered in
bold face.

P.S. Dirty hack, I know :-)

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:ee**************@TK2MSFTNGP12.phx.gbl...
Seems that there's a bug in the TreeNode object. When you change the font,
it does not readjust its size appropriately.

The following code shows the boldface text truncated with everything after
"W" removed.

private void Form1_Load(object sender, System.EventArgs e) {
TreeNode newNode = new TreeNode("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
treeView1.Nodes.Add(newNode);
newNode = new TreeNode("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
newNode.NodeFont = new Font(this.Font, FontStyle.Bold);
treeView2.Nodes.Add(newNode);
}

What I want to know is, how do I work around this? I need some of the nodes to be in bold!

Thanks,
Jon


Nov 15 '05 #2
Thank you. That makes it a documented bug, but still a bug. But the
workaround should work. Thanks.

Jon
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:uE**************@TK2MSFTNGP09.phx.gbl...
Hi Jon,

I agree this *looks* as a bug, but I believe this behavior is documented in MSDN that warns the text *will* be truncated if the node font is larger than the tree font. The trick I've used was to set the base tree font to bold,
and reset the boldness flag on all nodes that didn't need to be rendered in bold face.

P.S. Dirty hack, I know :-)

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Jon Davis" <jo*@REMOVE.ME.PLEASE.jondavis.net> wrote in message
news:ee**************@TK2MSFTNGP12.phx.gbl...
Seems that there's a bug in the TreeNode object. When you change the font, it does not readjust its size appropriately.

The following code shows the boldface text truncated with everything after "W" removed.

private void Form1_Load(object sender, System.EventArgs e) {
TreeNode newNode = new TreeNode("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
treeView1.Nodes.Add(newNode);
newNode = new TreeNode("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
newNode.NodeFont = new Font(this.Font, FontStyle.Bold);
treeView2.Nodes.Add(newNode);
}

What I want to know is, how do I work around this? I need some of the

nodes
to be in bold!

Thanks,
Jon

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Thomas Scheiderich | last post by:
I have the following page as test.aspx: *************************************************** <html> <head> <title>Hello and Welcome Page</title> </head> <body> <center> <% Dim CurrentDate As...
4
by: kristofera | last post by:
I am trying to do a distinct grouping of some nodes sorted by a numeric value but for some reason the distinct (preceding-sibling filter) is applied to the result as if not sorted. If I don't use...
6
by: Cro | last post by:
Dear Access Developers, The 'Allow Additions' property of my form is causing unexpected results. I am developing a form that has its 'Default View' property set to 'Continuous Forms' and am...
2
by: | last post by:
Hi everyone, I'm using VS.NET, Framework 1.1, Windows 2000 Server, IIS 5, all the latest patches are installed. Im having this wierd random problem, that I cannot reproduce but it happens...
1
by: Kuldeep | last post by:
When i export data from MySQL(server 5.0) i get followng error. SQLSTATE: 01004 String data, right truncated can sombody explain why this is happenning and possible solution!!! consider it...
7
by: TC | last post by:
I've produced an Access application for a client. For one report, text gets cut-off at the right margin when we print the report. It does this only when we print; it doesn't happen when we view the...
11
by: Ken Fine | last post by:
I am using VS.NET 2008 and like it a lot. One of the very few things I don't like is a bug that seems to spawn literally thousands of   strings, one after the other, on design view changes....
2
by: Dennis | last post by:
I am using VS 2005. I have a form with a TreeView. I want to change the font of the root node to bold. But when I do, running the program causes the text in that node to appear truncated ... as if...
12
by: Juan T. Llibre | last post by:
re: !I found an MSDN document that explains why what I'm trying to do should work Lee, From : http://www.w3.org/TR/REC-xml/ "A special attribute named xml:lang may be inserted in...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.