.net cf 2 c# measure string height with maximum width

  • Thread starter Thread starter mrpeter05
  • Start date Start date
M

mrpeter05

I can not find a way to measure the height of a string by setting a
maximum width!
I need the strings maximum width to be the width of the screen and
want to use that to calculate the height. Is this possible?
 
I need the strings maximum width to be the width of the screen and
want to use that to calculate the height. Is this possible?
MrPete,
in Petzold, Programming Windows in C#, Ch4,

you find something similar (you have to subclass Form):
Graphics grfx = CreateGraphics();
Sizef sizef;
float x, y =0;

sizef = grfx.MeasureString("YourStringHere", Font);
x = sizef.Width.
y = Font.Height.

I hope this helps,
Janos
 
MrPete,
in Petzold, Programming Windows in C#, Ch4,

you find something similar (you have to subclass Form):
Graphics grfx = CreateGraphics();
Sizef sizef;
float x, y =0;

sizef = grfx.MeasureString("YourStringHere", Font);
x = sizef.Width.
y = Font.Height.

I hope this helps,
Janos
sizef = grfx.MeasureString("YourStringHere", Font);
x = sizef.Width.
y = Font.Height.

what do I put after the "."? It always reports the same height!
 

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

Back
Top