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

TreeView node.Bounds.Width and DrawString

I am working on a custom treeView and have some problems with
a) node.Bounds.Width
b) concatenate strings drawn with DrawString(...)

a)
I want to highlight a selected node and used the node.Bounds dimensions
to draw a rectangle around the node but the node.Bounds.Width property
seems to be wrong. Sometimes the rectangle is too large and sometimes
it is too small; something like this

selectedNo(*)de
selectedNodeselect(*)edNode
selNod(*)e

(*) = the end of the rectangle - although the node.Bounds dimensions are used.
What can that be?

b)
I want to concatenate two strings drawn with DrawString.
How do I get the exact width of such a drawn string?
Or in other words - How do I get to know where to let the second string start?
Iīve tried something like this:

int width = this.node.Font.Size * text1.Length;

But of course that isnīt working...
Any ideas about these two topics?
Thanks really a lot for any hints!

Greetings,
timtos.
Nov 15 '05 #1
1 6031
Hi,

I have not looked at the node bounds. But on the point of the DrawString,
firstly why don't you concactenate the strings into a new string then draw
that string with one DrawString? Assuming you have good reason not to do
this, take a look at MeasureString it should help you.

Hope This Helps

Chris Taylor

"timtos" <ti****@gmx.de> wrote in message
news:bi***********@news.uni-koblenz.de...
I am working on a custom treeView and have some problems with
a) node.Bounds.Width
b) concatenate strings drawn with DrawString(...)

a)
I want to highlight a selected node and used the node.Bounds dimensions
to draw a rectangle around the node but the node.Bounds.Width property
seems to be wrong. Sometimes the rectangle is too large and sometimes
it is too small; something like this

selectedNo(*)de
selectedNodeselect(*)edNode
selNod(*)e

(*) = the end of the rectangle - although the node.Bounds dimensions are used. What can that be?

b)
I want to concatenate two strings drawn with DrawString.
How do I get the exact width of such a drawn string?
Or in other words - How do I get to know where to let the second string start? Iīve tried something like this:

int width = this.node.Font.Size * text1.Length;

But of course that isnīt working...
Any ideas about these two topics?
Thanks really a lot for any hints!

Greetings,
timtos.

Nov 15 '05 #2

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

Similar topics

6
by: Dean L. Howen | last post by:
Hi, I want to add some attributes to TreeNode, so I create a new class MyNode that inheritance from System.Windows.Forms.TreeNode, I want to TreeView use MyNode instead of TreeNode, so I can...
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:...
3
by: pamelafluente | last post by:
Hi I have some instances of a class: Class Myobject Public Color As Color Public Label As String End Class I need to show these instances on a treeview (which has checked boxes)
3
by: John | last post by:
I have overridden the default DrawNode (OwnerDrawText mode) to allow me to draw an extra icon at the front of the text block, while still using the built-in icon list for another icon. The problem...
8
by: Jon Slaughter | last post by:
I'm trying to override the default paiting of a treeview but I get bad results: My code(well, atleast this is the most simple that reproduces the result) is this private void TVDrawNode(Object...
1
by: watsod1 | last post by:
Hello, This is my first post, Hello to all. This also a test post to make sure that I am doing the right thing and following rules etc. I have been searching for a way to make the treeview...
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: John | last post by:
Hi All, I have a simple TreeView app that I need to color out certain nodes (draw text only). The problem is the root node (which is a normal node) will be unwantedly colored over when expanding...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: 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?
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...

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.