ev.graphics

  • Thread starter Thread starter max
  • Start date Start date
M

max

Is there a method in the Graphic to wrap a string into a rectangle?
If so is there a way to specify the width and let a Graphics method
determine how much vertical space is required? I tried using
..MeasureString but get weird numbers for the width and height.
({System.Drawing.SizeF}
Empty: {System.Drawing.SizeF}
Height: 21.248373
IsEmpty: False
Width: 40.8447266)

The SizeF I used for the layout rect was
Dim layoutSize As New SizeF(500.0F, 0.0F)

Thanks,
--max
 
Is there a method in the Graphic to wrap a string into a rectangle?

Have you had a look at all the overloaded DrawString methods? One does what
you need.
If so is there a way to specify the width and let a Graphics method
determine how much vertical space is required? I tried using
.MeasureString but get weird numbers for the width and height.
({System.Drawing.SizeF}
Empty: {System.Drawing.SizeF}
Height: 21.248373
IsEmpty: False
Width: 40.8447266)

The SizeF I used for the layout rect was
Dim layoutSize As New SizeF(500.0F, 0.0F)


Why are these values weired? We don't know the string you measured.

BTW, there's a specialized group for these questions:
microsoft.public.dotnet.framework.drawing


Armin
 
Thanks for the lead to the correct group.

-max

Have you had a look at all the overloaded DrawString methods? One does what
you need.



Why are these values weired? We don't know the string you measured.

BTW, there's a specialized group for these questions:
microsoft.public.dotnet.framework.drawing


Armin
 
Try

Dim sz As SizeF = gph.MeasureString(myString, MyFont, Width, MyStringFormat)

'sz will be returned with the height needed based on the string, width, and
alignment you want.
 
Back
Top