3
votes

I'm using Delphi 7 and Rave Reports. How can I set the DataText.Left property (from Rave Reports) dinamicaly according to the size of another DataText that comes before. I tried using the width from the previous DataText, the Length of the field that the first DataText is displaying... None of them worked. I would really appreciate it if anyone could give me any ideas.

Thanks

2

2 Answers

0
votes

The Length does not take the width of the characters into account, which will vary depending on the font settings.

// Assumes the AutoSize property is true.
// Note: 8 is added as spacing
DataText.Left := LastDataText.Left + LastDataText.Width + 8;

If your loading the data from a DataSet, have a look at the DisplayWidth property of the TField class.

// calculate the width of the last field.
TextWidth := DataSet.Fields[0].DisplayWidth * QuickReport.Canvas.TextWidth('M');
DataText.Left := LastDataText.Left + TextWidth;
0
votes

Alternatively, depending on the exact effect you need, you can also use just one datatext, and concatenate data/static text fields like this:

<FieldName> + ' Some text ' + <Param.ParamName> + ' Some other text'