Problem in right align of the text

  • Thread starter Thread starter Harpreet Singh via .NET 247
  • Start date Start date
H

Harpreet Singh via .NET 247

(Type your message here)

----------(Type your message here)
Hi
I want to align the text to be printed to be right aligned. I used stringalignment.far property but it instead started printing vertically from up to down.. While near and center seems to work fine.

BoxRectangle = New System.Drawing.RectangleF(Left, top, Width, Height)
AlignmentLabel = New System.Drawing.StringFormat(System.Drawing.StringAlignment.Far)
e.Graphics.DrawString(Value, FontLabel, System.Drawing.Brushes.Black, BoxRectangle, AlignmentLabel)

I am not able to find any reason for this ..hope someone will help me in solving this problem

Thanks
 
I want to align the text to be printed to be right aligned. I used stringalignment.far property but it instead started printing vertically from up to down.. While near and center seems to work fine.

BoxRectangle = New System.Drawing.RectangleF(Left, top, Width, Height)
AlignmentLabel = New System.Drawing.StringFormat(System.Drawing.StringAlignment.Far)
e.Graphics.DrawString(Value, FontLabel, System.Drawing.Brushes.Black, BoxRectangle, AlignmentLabel)

I am not able to find any reason for this ..hope someone will help me in solving this problem

Thanks
:

Try (untested):

BoxRectangle = New System.Drawing.RectangleF(Left, top, Width, Height)
SF = New System.Drawing.StringFormat()
SF.Alignment=System.Drawing.StringAlignment.Far
e.Graphics.DrawString(Value, FontLabel, System.Drawing.Brushes.Black,
BoxRectangle, SF)

You appear to be using the wrong parameter type on the StringFormat
Constructor.
I bet you have set "Option Strict Off"?

Michael
 
Back
Top