PC Review


Reply
Thread Tools Rate Thread

TreeView node in bold has incorrect length

 
 
Marcel Brekelmans
Guest
Posts: n/a
 
      13th Jan 2007
Hi,

When I set the text of a TreeView node to bold (or Italic for that matter)
programmatically, it doesn't show up with its length adjusted. Instead, it
has the length of the text in normal font, so it is clipped at the end. Does
anyone know of a workaround?

Thanks


 
Reply With Quote
 
 
 
 
Michael A. Covington
Guest
Posts: n/a
 
      13th Jan 2007

"Marcel Brekelmans" <(E-Mail Removed)> wrote in message
news:-(E-Mail Removed)...
> Hi,
>
> When I set the text of a TreeView node to bold (or Italic for that matter)
> programmatically, it doesn't show up with its length adjusted. Instead, it
> has the length of the text in normal font, so it is clipped at the end.
> Does anyone know of a workaround?
>
> Thanks



Not exactly, but try changing the font of the TreeView from "MS Sans Serif"
to Tahoma. In fact, do that to your whole form and make sure the TreeView
inherits it. "MS Sans Serif" is the default font of older .NET versions and
is a flawed font -- I have had other problems with its spacing and width.

See this:
http://www.covingtoninnovations.com/...ex.html#060312



 
Reply With Quote
 
 
 
 
Marcel Brekelmans
Guest
Posts: n/a
 
      13th Jan 2007
Hi Michael,

I tried your solution. Unfortunately, it doesn't help: the textlength is
still based on the 'Normal' font.

However, I came across another approach which does a good job: make the font
of the TreeView Bold in the constructor. For each TreeNode you add, make its
font Normal. That way, the length of the TreeNode.Text is based on the Bold
font and when you make it actually bold it is not clipped.

Thanks anyway.
"Michael A. Covington" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
>
> "Marcel Brekelmans" <(E-Mail Removed)> wrote in message
> news:-(E-Mail Removed)...
>> Hi,
>>
>> When I set the text of a TreeView node to bold (or Italic for that
>> matter) programmatically, it doesn't show up with its length adjusted.
>> Instead, it has the length of the text in normal font, so it is clipped
>> at the end. Does anyone know of a workaround?
>>
>> Thanks

>
>
> Not exactly, but try changing the font of the TreeView from "MS Sans
> Serif" to Tahoma. In fact, do that to your whole form and make sure the
> TreeView inherits it. "MS Sans Serif" is the default font of older .NET
> versions and is a flawed font -- I have had other problems with its
> spacing and width.
>
> See this:
> http://www.covingtoninnovations.com/...ex.html#060312
>
>
>



 
Reply With Quote
 
Frans Bouma [C# MVP]
Guest
Posts: n/a
 
      14th Jan 2007
Marcel Brekelmans wrote:

> Hi,
>
> When I set the text of a TreeView node to bold (or Italic for that
> matter) programmatically, it doesn't show up with its length
> adjusted. Instead, it has the length of the text in normal font, so
> it is clipped at the end. Does anyone know of a workaround?


This is an issue in windows. I ran into this as well some time ago and
decided to go with an alternative color instead. The workaround, which
you probably won't like, is to set all texts to bold initially and then
programmatically set every node's text which has to be normal looking
to normal font.

If I'm not mistaken, Raymond Chen (The 'OldNewThing' blog) blogged
about the reason for this some time ago, but I can't find the exact
link. What I do know is that it's an issue in windows.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Treeview : Adding a node to a specific existing node with Net 1.0(work with 2.0) michelqa@yahoo.ca Microsoft C# .NET 2 12th Jun 2008 08:18 AM
TreeView node style - for an individual node Homer J. Simpson Microsoft ASP .NET 5 24th Jul 2007 11:04 PM
How to find node in TreeView by using string(the same as Node.Text) ? jiing Microsoft ASP .NET 0 27th Apr 2007 03:34 AM
Context menu popup on treeview node returning wrong selected node Claire Microsoft C# .NET 2 5th Mar 2007 12:59 PM
How can I determine the node number of a node in my treeview meh Microsoft VB .NET 2 4th Sep 2003 04:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:39 AM.