Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / September 2005

Tip: Looking for answers? Try searching our database.

TreeView... label width

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hzgt9b@nopost.com - 21 Sep 2005 20:48 GMT
Using VS.NET 2003, VB:
I have a TreeView object with lots of nodes. The treeview is docked on the
left side of my main from in a splitter. I want to set the splitter's initial
width to allow all the treeViews' nodes' labels to be visible.

The algorithm is simple, for each node in the tree view compare node's label
with the max width, and so on. The problem that I've got is how do I discover
the width of a TreeView's label? All I can find is the Text property - and
that doesn't translate well into a pixel width.

Any suggestions?
Oliver Sturm - 22 Sep 2005 10:15 GMT
>Using VS.NET 2003, VB:
>I have a TreeView object with lots of nodes. The treeview is docked on the
[quoted text clipped - 8 lines]
>the width of a TreeView's label? All I can find is the Text property - and
>that doesn't translate well into a pixel width.

You'll have to calculate the width yourself, using the
Graphics.MeasureString method. While I was looking for a link to give you,
I found that there's actually an example of this very thing on the MSDN
page about the Control.CreateGraphics method: http://shrinkster.com/87i

               Oliver Sturm
Signature

Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)

hzgt9b@nopost.com - 22 Sep 2005 13:50 GMT
Thanks for the link...

> >Using VS.NET 2003, VB:
> >I have a TreeView object with lots of nodes. The treeview is docked on the
[quoted text clipped - 15 lines]
>
>                 Oliver Sturm
hzgt9b@nopost.com - 30 Sep 2005 13:46 GMT
I need to inspect each node in the treeView. But unfortunately the
CreateGraphics() method is available for TreeNode objects. Any other ideas on
how to interrogate the tree node to gets its pixel width?

> >Using VS.NET 2003, VB:
> >I have a TreeView object with lots of nodes. The treeview is docked on the
[quoted text clipped - 15 lines]
>
>                 Oliver Sturm
Oliver Sturm - 30 Sep 2005 14:04 GMT
>I need to inspect each node in the treeView. But unfortunately the
>CreateGraphics() method is available for TreeNode objects. Any other ideas
>on
>how to interrogate the tree node to gets its pixel width?

You should be able to use any other Graphics object for the task. You
could query one from the TreeView control, or even create your own from a
bitmap or other source.

               Oliver Sturm
Signature

Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.