TextRenderer::MeasureText Method (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.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- text
-
Type:
System::String^
The text to measure.
- font
-
Type:
System.Drawing::Font^
The Font to apply to the measured text.
- proposedSize
-
Type:
System.Drawing::Size
The Size of the initial bounding rectangle.
The MeasureText method uses the proposedSize parameter to indicate the relationship of height to width when determining the text size. When measuring text on a single line, if the proposedSize parameter represents a Size with a height dimension greater than Int32::MaxValue, the returned Size will be adjusted to reflect the actual height of the text.
The following code example demonstrates how to use one of the MeasureText methods. To run this example, paste the code into a Windows Form and call DrawALineOfText from the form's Paint event handler, passing e as PaintEventArgs.
Available since 2.0