views:

147

answers:

2

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

A: 

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;
stukelly
I have not tested the above code. I need to check the *QuickReport.Canvas* is correct.
stukelly
A: 

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'
Tobiasopdenbrouw