Auto width adjustment for textbox in Crystal Reports 2008

Posted on 2009-12-29
Last Modified: 2012-05-08
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}.

Question by:StanT
    LVL 77

    Accepted Solution

    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.

    LVL 100

    Expert Comment

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Hi, I am very much excited today since I'm going to share something very exciting Tool used for Analytical Reporting and that's nothing but MICROSTRATEGY. Actually there are lot of other tools available in the market for Reporting Such as Co…
    I recently went through setting up a JasperReports Server using the AWS EC2 instance, and this article will cover some basic administration tasks I had to perform.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now