Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Suggestions - Aligning part of string to left and other part to right

edited June 2013 in General
I need suggestions on how to solve this problem. I am printing labels
that show a list of ingredients like this:

Ingredient1 10%
Other Ingredients 90%

I need to be able to left align the ingredient part and right align the
% part. Any ideas on how to achieve this?

Thanks,

David

Comments

  • edited June 2013
    Hi David,

    You will need to split each ingredient into two parts (or two strings),
    then place one in a left aligned label, and the other in a right aligned
    label on the report.

    Your best bet would be to find the position of the right-most space
    character then split the strings into two there. This could be done
    fairly easily using the Pos and Copy Delphi routines.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited June 2013
    Hi Nico,

    I figured out that part, but if the ingredient is forced to wrap, I need
    to force an extra line in the second list, to make sure the % is lined
    up with the bottom line of the ingredient. I'm looking at using
    Canvas.TextWidth procedure, but RB doesn't like it.

    Any ideas for that?

  • edited June 2013
    Hi David,

    When using Canvas.TextWidth, the result will use the units of the
    canvas. For instance, if you create a TBitmap and use its Canvas, you
    will be measuring text in screen pixels.

    ReportBuilder uses the report units defined by the Report.Units
    property. When using measurements, you need to be sure you convert the
    results accordingly. Take a look at the ppUtils.pas file for some
    useful conversion utilities.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.