Auto Width text problem

I want the red circled text always followed by blue circled text which the width is not fixed.

What I have done:
- Enable blue circled text autoWidth
- Capture blue circled onAfterPrint even and redCircledText.Left = blueCircledText.calcWidth();

But still no luck, anything wrong?


Thanks in advance

fastreport_problem.png

Comments

  • edited 3:13PM
    Use that code in onAfterData instead of onAfterPrint
  • Hello!

    The AfterPrint event is triggered only after the object and its band have been drawn on the generated page; therefore, changing the Left property within the AfterPrint event does not affect the current row. You need to change the position of the adjacent TextObject in the AfterData event (after data binding, but before printing).

    Calculating the coordinate and the method name: In the FastReport C# script, the method is defined in `CalcWidth()`, and the `Left` coordinate of the second object should be calculated relative to the left edge of the first one (`blueCircledText.Left + blueCircledText.CalcWidth()`).

    Example of a working handler in the report script:

    private void blueCircledText_AfterData(object sender, EventArgs e)
    {
    // If necessary, add an offset in pixels, for example, +5f
    redCircledText.Left = blueCircledText.Left + blueCircledText.CalcWidth();
    }
    
This discussion has been closed.