Right-Justify Variable-Pitch Font?

P

PeteCresswell

Got a TreeView.

Top node is the name of a company concatonated with some numbers about
the company.

Users want company name on the left and the numbers on the right.

Tried a few monospaced fonts, but the tree's readability goes down the
tubes.

Seems like there ought tb an API call or something where I feed it a
text string, text size, and a font name and it returns something like
the width of the rendered text.

Using that, I could right-justify no matter if the font is variable-
pitch.

Anybody been here?
 
P

PeteCresswell

Anybody been here?

I should add that I've used routines that compute the width of a text
box's contents... but in this case we have not text box. Just an
ASCII string and the name/props of the font.

I guess one workaround would be to open up a little invisible form
with a text box on it, load the text box control with the text in
question, and work from there. But that sounds like it might raise
performance issues when building a large tree....
 
S

Stephen Lebans

Hi Pete,
have a peek here:
http://www.lebans.com/textwidth-height.htm
BUG FIX!!!!!!! Thanks to Marshall Barton for the "Hey it's great but I don't
think it works perfectly" Email. I finally took the time to figure out
exactly what is going on when Access renders text. Unfortunately now I have
to go back and update all of my other projects to make them as accurate as
this one!

TextHeightWidth.zip is a replacement for the Report object's TextWidth and
TextHeight methods. It is multiline aware and can work in both Report and
Form views. Includes a sample report to show you how to autosize individual
controls with different formatting on the same line to simulate RTF style
text.



History

Version 4.5: Increased accuracy of auto sizing for a ListBox.

Version 4.3: Added sample Form to demonstrate auto sizing for a ListBox.

Version 4.2: Added report to demonstrate auto sizing to mix text formatting
on one row.

Version 4.1: First Release that works!!!<grin>

Version 1.0: First Release
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
P

(PeteCresswell)

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top