The lenght of a text string 
Author Message
 The lenght of a text string

How can I get the lenght of a string in pixels when using a specific font.

I am using the
System.Windows.Forms.PaintEventArgs.Graphics.DrawString()

Thanks,

Michael



Sun, 05 Jun 2005 21:29:14 GMT  
 The lenght of a text string
System.Windows.Forms.PaintEventArgs.Graphics

Has a
MeasureString

method

You need to pass in your String of text to draw and a new Font object which
takes in Font Name and Size

Graphics.MeasureString("Text Here",new Font("Arial",16))

Joe


Quote:
> How can I get the lenght of a string in pixels when using a specific font.

> I am using the
> System.Windows.Forms.PaintEventArgs.Graphics.DrawString()

> Thanks,

> Michael



Sun, 05 Jun 2005 21:56:51 GMT  
 The lenght of a text string
Thanks a lot, works fine.

Quote:
> System.Windows.Forms.PaintEventArgs.Graphics

> Has a
> MeasureString

> method

> You need to pass in your String of text to draw and a new Font object
which
> takes in Font Name and Size

> Graphics.MeasureString("Text Here",new Font("Arial",16))

> Joe



> > How can I get the lenght of a string in pixels when using a specific
font.

> > I am using the
> > System.Windows.Forms.PaintEventArgs.Graphics.DrawString()

> > Thanks,

> > Michael



Sun, 05 Jun 2005 22:07:54 GMT  
 The lenght of a text string
Micheal,
    Also make sure to use StringFormat.GenericTypographic to measure the
string if you don't want 'padding' around the string included.  There have
been many long discussions of MeasureString and its current limitations in
microsoft.public.dotnet.framework.drawing.

Ron Allen

Quote:
> System.Windows.Forms.PaintEventArgs.Graphics

> Has a
> MeasureString

> method

> You need to pass in your String of text to draw and a new Font object
which
> takes in Font Name and Size

> Graphics.MeasureString("Text Here",new Font("Arial",16))

> Joe



> > How can I get the lenght of a string in pixels when using a specific
font.

> > I am using the
> > System.Windows.Forms.PaintEventArgs.Graphics.DrawString()

> > Thanks,

> > Michael



Sun, 05 Jun 2005 22:54:57 GMT  
 The lenght of a text string
Can these methods be used to set the width of a grid column in a gridtable
style?
Or is there a better way to dynamically set column widths?


Quote:
> Micheal,
>     Also make sure to use StringFormat.GenericTypographic to measure the
> string if you don't want 'padding' around the string included.  There have
> been many long discussions of MeasureString and its current limitations in
> microsoft.public.dotnet.framework.drawing.

> Ron Allen


> > System.Windows.Forms.PaintEventArgs.Graphics

> > Has a
> > MeasureString

> > method

> > You need to pass in your String of text to draw and a new Font object
> which
> > takes in Font Name and Size

> > Graphics.MeasureString("Text Here",new Font("Arial",16))

> > Joe



> > > How can I get the lenght of a string in pixels when using a specific
> font.

> > > I am using the
> > > System.Windows.Forms.PaintEventArgs.Graphics.DrawString()

> > > Thanks,

> > > Michael



Mon, 06 Jun 2005 16:12:17 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. calc lenght of string in form as you type

2. Help: Cannot contain zero-lenght string error

3. Lenght of text in a shell command

4. T-SQL6.5: To detemine the excact lenght of data in TEXT field

5. Parsing a large text string into smaller strings?

6. Help parse a text string from sequential text file

7. Search for a text string in text file

8. Text Box to rotate a text string

9. How to replace text string in text file

10. MCI control: like convert frames lenght in seconds lenght?

11. MAIL BODY LENGHT PROBLEM

12. lenght is reported as zero in filesystemwatcher

 

 
Powered by phpBB® Forum Software