Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TreeView Text Width Calculation Bug

20 views
Skip to first unread message

Bill Henning

unread,
Jan 25, 2002, 3:21:42 PM1/25/02
to
If I have a TreeView and fill it with nodes and then decide to change one of
the node's font styles to bold, the end of the text in that node gets
chopped off. It seems like the TreeView isn't taking the NodeFont's style
into account when calculating the width of the text. Here's the code to
make it happen on a node named treeNode in a TreeView named treeView:

treeNode.NodeFont = new Font(treeView.Font, FontStyle.Bold);

In this example, making the font bolder widens the text but the TreeView
doesn't adjust for this. I am using RTM by the way.

--
Bill Henning
Actipro Software LLC

Check out our .NET components at:
http://www.actiprosoftware.com/products/dotnet/


Jacob Grass (MVP)

unread,
Jan 25, 2002, 3:51:22 PM1/25/02
to
This is an old issue with the TreeView. The Platform SDK says the
following:

"For Version 5.0 of the common controls, these two controls may display
clipped text if you change the font by returning CDRF_NEWFONT. This behavior
is necessary for backward compatibility with earlier versions of the common
controls. If you want to change the font of a list-view or tree-view
control, you will get better results if you send a CCM_SETVERSION message
with the wParam value set to 5 before adding any items to the control."

And, the docs say the following:

"If the node font is larger than the Font property value set in the TreeView
control, the tree node label text is clipped."

A way around this is to set the Font of the treeview to be bolded and then
unbold the nodes you don't want bolded. . .

--
Jacob Grass
Microsoft .NET MVP

"Bill Henning" <ju...@actiprosoftware.com> wrote in message
news:uw3ut3dpBHA.1532@tkmsftngp03...

Nathan Alden

unread,
Jan 26, 2002, 1:32:29 PM1/26/02
to
You'd think Microsoft would fix these stupid little bugs by now. Sometimes
the littlest bugs are the most annoying.

Nate

"Jacob Grass (MVP)" <JGr...@AbilitiSolutions.com> wrote in message
news:#ciSOIepBHA.1744@tkmsftngp03...

0 new messages