TextRenderer::MeasureText Method (IDeviceContext^, String^, Font^)
.NET Framework (current version)
Provides the size, in pixels, of the specified text drawn with the specified font in the specified device context.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- dc
-
Type:
System.Drawing::IDeviceContext^
The device context in which to measure the text.
- text
-
Type:
System::String^
The text to measure.
- font
-
Type:
System.Drawing::Font^
The Font to apply to the measured text.
Return Value
Type: System.Drawing::SizeThe Size, in pixels, of text drawn in a single line with the specified font in the specified device context.
The MeasureText method requires that the text is drawn on a single line.
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.
.NET Framework
Available since 2.0
Available since 2.0
Show: