473,386 Members | 1,630 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,386 software developers and data experts.

TreeView... label width

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?
Sep 21 '05 #1
4 2735
hz****@nopost.com wrote:
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.


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
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Sep 22 '05 #2
Thanks for the link...

"Oliver Sturm" wrote:
hz****@nopost.com wrote:
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.


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
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)

Sep 22 '05 #3
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?

"Oliver Sturm" wrote:
hz****@nopost.com wrote:
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.


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
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)

Sep 30 '05 #4
hz****@nopost.com wrote:
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
--
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
Sep 30 '05 #5

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

Similar topics

42
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
3
by: Steve Richter | last post by:
in windows explorer, the nodes immed under the "my computer" root node appear with a minimum of indenting ( the +/- square is directly underneath the root node ). In the .NET TreeView control the...
2
by: Peter Flickinger | last post by:
I have been using a label with the TreeView control - to simulate the ghost image of a node during drag/drop (so that a ghost of the node appears to be floating next to the cursor on a drag/drop)....
1
by: nicholas | last post by:
I am using Obout TreeView: www.obout.com I would like to implement a page to add and remove categories to a product with the Obout Treeview with checkboxes. Does anyone allready did this and...
4
by: hzgt9b | last post by:
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...
5
by: lanem | last post by:
I want to display some drill-down data with a datagrid look. I can get the exact functionality I want with a treeview, but I don't like the way the treeview looks and formats the data. I want a...
0
by: deko | last post by:
I'm trying to implement a custom TreeView that shows a ghost image while dragging. But the form I'm using is different from the sample code found here:...
18
by: =?Utf-8?B?TGkgV2VuZw==?= | last post by:
Hi, Is there a way for TreeView to have multiple selections? But I am not talking about its checked boxes. I want a way similar to ListView with MultiSelect = True. So I can use or key and...
0
by: bsturg21 | last post by:
Hello, I have an app that has a custom treeview which inherits the base treeview class and I am having a problem with the way the treeview is being redrawn. Each node in the treeview represents a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.