M mmobile Dec 3, 2005 #1 How can I get the size (in pixels) of a string's display width (based on the Font used)?
D Dinesh Bajaj Dec 3, 2005 #2 By using Graphics' object MeasureString method. e.g. Dim textWidth as integer = Convert.ToInt32(Me.CreateGraphics.MeasureString(lblName.Text, lblName.Font).Width)
By using Graphics' object MeasureString method. e.g. Dim textWidth as integer = Convert.ToInt32(Me.CreateGraphics.MeasureString(lblName.Text, lblName.Font).Width)
S Sergey Bogdanov Dec 3, 2005 #3 Use MeasureString for that: using(Graphics g = (new Control()).CreateGraphics()) { SizeF sz = g.MeasureString("Hello World", SpecificFont); }
Use MeasureString for that: using(Graphics g = (new Control()).CreateGraphics()) { SizeF sz = g.MeasureString("Hello World", SpecificFont); }
M mmobile Dec 5, 2005 #4 Thanks for the help. Sergey Bogdanov said: Use MeasureString for that: using(Graphics g = (new Control()).CreateGraphics()) { SizeF sz = g.MeasureString("Hello World", SpecificFont); } -- Sergey Bogdanov [.NET CF MVP, MCSD] http://www.sergeybogdanov.com How can I get the size (in pixels) of a string's display width (based on the Font used)? Click to expand... Click to expand...
Thanks for the help. Sergey Bogdanov said: Use MeasureString for that: using(Graphics g = (new Control()).CreateGraphics()) { SizeF sz = g.MeasureString("Hello World", SpecificFont); } -- Sergey Bogdanov [.NET CF MVP, MCSD] http://www.sergeybogdanov.com How can I get the size (in pixels) of a string's display width (based on the Font used)? Click to expand... Click to expand...