TreeView Control Column Widths

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using a TreeView Control to display multiple columns of data. The data
is of varying lengths so that it is not displayed in neat columns. This is a
known limitation and Microsoft says you can test for the length of the data
and then add padding spaces. This makes sense to me but I have know idea how
to go about it. I know how to determine the difference between the width of
the data and my ideal column width but how would I then say add x number of
spaces to the end of the data.

Any guidance is greatly appreciated!
 
Hi,
to get a text width for certain font - you can use GetTextExtentPoint32A API
function (just Google for it)
but what do you mean with columns in treeview?
 
I guess technically there not columns they are just piece of data. In my case
I am displaying Project Number then Project Name then Status all on the same
node.
Because Project name is not always the same length string my Status fields
don't line up.

I get something like this.

001 Project Name One Pending
002 Project Name 2 Pending
003 Project Name Three Pending

When what I'd like is:

001 Project Name One Pending
002 Project Name 2 Pending
003 Project Name Three Pending

Hope that makes sense.

Thanks!
--
Michal Joyce
Project Management IS Analyst
Aflac - Project Management Office


Alex Dybenko said:
Hi,
to get a text width for certain font - you can use GetTextExtentPoint32A API
function (just Google for it)
but what do you mean with columns in treeview?
 
ahh, now I see,
I think you can get best results, if you use fixed font in your treeview
(courier for example) - then you can easy calculate number of spaces you
need to add.
BTW, you can also consider using other controls, with combination of
treeview and grid, for example look at www.vbaccelerator.com

--
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


MJatAflac said:
I guess technically there not columns they are just piece of data. In my
case
I am displaying Project Number then Project Name then Status all on the
same
node.
Because Project name is not always the same length string my Status fields
don't line up.

I get something like this.

001 Project Name One Pending
002 Project Name 2 Pending
003 Project Name Three Pending

When what I'd like is:

001 Project Name One Pending
002 Project Name 2 Pending
003 Project Name Three Pending

Hope that makes sense.

Thanks!
 
Thanks for the site. Very cool stuff.

As to calculating the number of spaces - can do... My question is how do I
use that number once I have it. I suppose I could use a loop to add a space
to the end of the data one at a time until my counter reached the number of
spaces I need but this seems a bit inefficient to me...

m
 
Hi,
if you use fixed font - then say your column width is 10 spaces - you
expression will look like:

strCol=strVal & space(10 -len(strVal))
something like this
 
Back
Top