jakekula
asked on
Right Align a DrawString
Hi Guys,
I'm probably asking about the impossible but I'll give it a go anyway.
Can I right align a DrawString...? I realise that it is drawn with x and y axes and is measured from the top-left hand corner of the DrawString. The only way would probably be to make the DrawString measure from the top-righ hand corner and go right to left instead of left to right.
My code is below:
text = "Net Sales Value"
e.Graphics.DrawString(text , printFont2, System.Drawing.Brushes.Bla ck, 510, 230)
text = "Tax Value"
e.Graphics.DrawString(text , printFont2, System.Drawing.Brushes.Bla ck, 610, 230)
Any suggestions?
Thanks in advance...
JK
I'm probably asking about the impossible but I'll give it a go anyway.
Can I right align a DrawString...? I realise that it is drawn with x and y axes and is measured from the top-left hand corner of the DrawString. The only way would probably be to make the DrawString measure from the top-righ hand corner and go right to left instead of left to right.
My code is below:
text = "Net Sales Value"
e.Graphics.DrawString(text
text = "Tax Value"
e.Graphics.DrawString(text
Any suggestions?
Thanks in advance...
JK
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
it is much easier than that, just use the stringformat
Dim recf As New RectangleF(0, 0, 300, 20)
Dim hh As New StringFormat
hh.Alignment = StringAlignment.Far
g.DrawString("hello", Me.Font, New SolidBrush(Color.Black), recf, hh)
this will right align in the rectangle recf