0 out of 1 rated this helpful - Rate this topic

TextRenderer.MeasureText Method

Measures the specified text when drawn with the specified font.

This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.

  Name Description
Public method Static member MeasureText(String, Font) Provides the size, in pixels, of the specified text when drawn with the specified font.
Public method Static member MeasureText(IDeviceContext, String, Font) Provides the size, in pixels, of the specified text drawn with the specified font in the specified device context.
Public method Static member MeasureText(String, Font, Size) Provides the size, in pixels, of the specified text when drawn with the specified font, using the specified size to create an initial bounding rectangle.
Public method Static member MeasureText(IDeviceContext, String, Font, Size) Provides the size, in pixels, of the specified text when drawn with the specified font in the specified device context, using the specified size to create an initial bounding rectangle for the text.
Public method Static member MeasureText(String, Font, Size, TextFormatFlags) Provides the size, in pixels, of the specified text when drawn with the specified font and formatting instructions, using the specified size to create the initial bounding rectangle for the text.
Public method Static member MeasureText(IDeviceContext, String, Font, Size, TextFormatFlags) Provides the size, in pixels, of the specified text when drawn with the specified device context, font, and formatting instructions, using the specified size to create the initial bounding rectangle for the text.
Top
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Incorrect size, height or width

Set the From.AutoScaleMode to Dpi, if it is set to Font, string measurements for labels and controls will not be correct. Note this does impact scaling for different screen sizes.