Length to pixel transform

  • Thread starter Thread starter Pumkin
  • Start date Start date
P

Pumkin

Hello everyone...
I have a question for all of you cause sincerelly I'm stuck.
I have a string and I can get its length.
For example : The string ASP. The length is 3.
How can I know how many pixels is the length.

Thanks a lot in advanced,
 
Pumkin said:
Hello everyone...
I have a question for all of you cause sincerelly I'm stuck.
I have a string and I can get its length.
For example : The string ASP. The length is 3.
How can I know how many pixels is the length.

Thanks a lot in advanced,


Take a look at the MeasureString method of the System.Drawing.Graphics
class - you give it a string and a font object, and it returns you a
size.

http://msdn.microsoft.com/library/d...emdrawinggraphicsclassmeasurestringtopic1.asp
 
you can only know the size on the server, you will have to render it on the
client, and use javascript to estimate the length (as the browser does not
expose and api for this).

-- bruce (sqlwork.com)
 
Back
Top