473,386 Members | 1,846 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 2734
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.