System.Windows.Forms.TextRenderer.MeasureText Method

Provides the size, in pixels, of the specified text drawn with the specified font in the specified device context.

Syntax

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

Parameters

dc
The device context in which to measure the text.
text
The text to measure.
font
The System.Drawing.Font to apply to the measured text.

Returns

The System.Drawing.Size, in pixels, of text drawn in a single line with the specified font in the specified device context.

Remarks

The TextRenderer.MeasureText(System.Drawing.IDeviceContext, string, System.Drawing.Font) method requires that the text is drawn on a single line.

Requirements

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