How to position one controll relative to another.
I need to display two DBText Fields, next to each other.
The leftmost one, is aligned left. DBText1
The Rightmost one is aligned left. DBText2
The leftmost one contains a variable length integer.
The rightmost one represents a statistical accuracy integer, and must appear
to the (R) of the last digit of DBText1, as a subscript.
eg
100
10
or
123456
99
or
1
10
so the DBtext2 field needs to move right, depending on the length of DBText1
field.
How do I achieve this at report runtime?
I hope somebody can help
Regards
Adrian
The leftmost one, is aligned left. DBText1
The Rightmost one is aligned left. DBText2
The leftmost one contains a variable length integer.
The rightmost one represents a statistical accuracy integer, and must appear
to the (R) of the last digit of DBText1, as a subscript.
eg
100
10
or
123456
99
or
1
10
so the DBtext2 field needs to move right, depending on the length of DBText1
field.
How do I achieve this at report runtime?
I hope somebody can help
Regards
Adrian
This discussion has been closed.
Comments
Try calculating the text width of DBText2 in its OnGetText event. Then
using this information, set the position of the other DBText component. The
easiest way to discover the text width of a string is to creat a TBitmap and
use its TCanvas.TextWidth routine.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks, could you perhaps give more detail for the next part of your answer
The
I take the content of the string at runtime .
How does the bitmap come into the picture?
Perhaps if you could allude to an example, I would appreciate very much!
Thanks
Adrian
Say for instance you have two DBText objects. In the OnGetText event you
would do something like the following to determine the width of the DBText
so you can position the second one accordingly.
Psuedo Code...
uses
ppUtils;
lBitMap := TBitmap.Create;
lCanvas := TBitmap.Canvas;
lCanvas.Font := DBText1.Font;
liSPWidth := lCanvas.TextWidth(aText);
//convert to Report Units (inches in this case)
ldTextWidth := ppFromScreenPixels(liSPWidth, utInches, pprtHorizontal , nil)
DBText2.Left := DBText1.Left + ldTextWidth + 0.25;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com