System.Windows.Forms.TextRenderer.MeasureText Method

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.

Syntax

public static System.Drawing.Size MeasureText (string text, System.Drawing.Font font, System.Drawing.Size proposedSize)

Parameters

text
The text to measure.
font
The System.Drawing.Font to apply to the measured text.
proposedSize
The System.Drawing.Size of the initial bounding rectangle.

Returns

The System.Drawing.Size, in pixels, of text drawn with the specified font.

Remarks

The TextRenderer.MeasureText(string, System.Drawing.Font, System.Drawing.Size) 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 System.Drawing.Size with a height dimension greater than int.MaxValue, the returned System.Drawing.Size will be adjusted to reflect the actual height of the text.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0