ev.graphics

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
 
A

Armin Zingler

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
 
M

max

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top