|
-
Mar 5th, 2004, 10:04 AM
#1
Thread Starter
Registered User
Width of a string
How can I measure the width of the string which I draw on a Graphics object?
-
Mar 5th, 2004, 02:24 PM
#2
Sleep mode
This way .
Code:
protected override void OnPaint(PaintEventArgs e)
{
SizeF stringSize=new SizeF();
SizeF=e.Graphics.MeasureString("Your text here",stringSize,Myfont);
}
-
Mar 5th, 2004, 06:23 PM
#3
Originally posted by Pirate
This way .
Code:
protected override void OnPaint(PaintEventArgs e)
{
SizeF stringSize=new SizeF();
SizeF=e.Graphics.MeasureString("Your text here",stringSize,Myfont);
}
I dont know if it would be helpful but: just remember that SizeF is in decimal format, so if you are rounding it or converting it to integer I would suggest using Math.Ceiling. I was using this in VB and was a few pixels short depending on the system font size and couldnt figure it out, until I found out that it was a rounding problem
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Mar 6th, 2004, 05:25 AM
#4
Sleep mode
Remember can affect the result taken by MeasureString method .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|