• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1464
  • Last Modified:

Auto width adjustment for textbox in Crystal Reports 2008

Hi Experts,

I'm looking for a simple formula to place in the width adjustment formula to auto expand a textbox based on the number of charactors in the text box.

My textbox pulls it's info from two table columns: {lastname},{firstname}.

Thanks
Stan
0
StanT
Asked:
StanT
1 Solution
 
peter57rCommented:
Unless you are using a fixed width font (of which there are very few) then there is no 'simple' formula that will do this.
The width of 35 i's is quite different to 35 w's  for a normal proportional font.

For '{lastname},{firstname}' you can get the length of the fields using:
numbervar mylen;
mylen:= len({table.lastname} & {table.firstname} +1)
if you use a 10cpi font such as courier then you can just multiply mylen by .1 to get the width in inches.
But for any 'normal' font you have to know the width of every character to get a proper answer.
CR itself just takes an 'average' character width when it sets the default size of a textbox.  But you would have to find such a measurememt and store it as a constant in the formula.

0
 
mlmccCommented:
I agree with Peter, it is not an easy task unless you use a fixed-width font like Courier.  There are others but i couldn't name one.

There are algorithms you can use to get the width of a string.  The algorithms are printer dependent.

I took a quick look and couldn't find one.

mlmcc
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now