DataGridViewCell.MeasureTextHeight Method

Definition

Gets the height, in pixels, of the specified text.

Overloads

MeasureTextHeight(Graphics, String, Font, Int32, TextFormatFlags, Boolean)

Gets the height, in pixels, of the specified text, given the specified characteristics. Also indicates whether the required width is greater than the specified maximum width.

MeasureTextHeight(Graphics, String, Font, Int32, TextFormatFlags)

Gets the height, in pixels, of the specified text, given the specified characteristics.

MeasureTextHeight(Graphics, String, Font, Int32, TextFormatFlags, Boolean)

Gets the height, in pixels, of the specified text, given the specified characteristics. Also indicates whether the required width is greater than the specified maximum width.

public:
 static int MeasureTextHeight(System::Drawing::Graphics ^ graphics, System::String ^ text, System::Drawing::Font ^ font, int maxWidth, System::Windows::Forms::TextFormatFlags flags, [Runtime::InteropServices::Out] bool % widthTruncated);
public static int MeasureTextHeight (System.Drawing.Graphics graphics, string text, System.Drawing.Font font, int maxWidth, System.Windows.Forms.TextFormatFlags flags, out bool widthTruncated);
public static int MeasureTextHeight (System.Drawing.Graphics graphics, string? text, System.Drawing.Font font, int maxWidth, System.Windows.Forms.TextFormatFlags flags, out bool widthTruncated);
static member MeasureTextHeight : System.Drawing.Graphics * string * System.Drawing.Font * int * System.Windows.Forms.TextFormatFlags * bool -> int
Public Shared Function MeasureTextHeight (graphics As Graphics, text As String, font As Font, maxWidth As Integer, flags As TextFormatFlags, ByRef widthTruncated As Boolean) As Integer

Parameters

graphics
Graphics

The Graphics used to render the text.

text
String

The text to measure.

font
Font

The Font applied to the text.

maxWidth
Int32

The maximum width of the text.

flags
TextFormatFlags

A bitwise combination of TextFormatFlags values to apply to the text.

widthTruncated
Boolean

Set to true if the required width of the text is greater than maxWidth.

Returns

The height, in pixels, of the text.

Exceptions

graphics is null.

-or-

font is null.

maxWidth is less than 1.

flags is not a valid bitwise combination of TextFormatFlags values.

Remarks

If multiple lines are required and the specified formatting allows it, the height returned is the combined height of all lines.

See also

Applies to

MeasureTextHeight(Graphics, String, Font, Int32, TextFormatFlags)

Gets the height, in pixels, of the specified text, given the specified characteristics.

public:
 static int MeasureTextHeight(System::Drawing::Graphics ^ graphics, System::String ^ text, System::Drawing::Font ^ font, int maxWidth, System::Windows::Forms::TextFormatFlags flags);
public static int MeasureTextHeight (System.Drawing.Graphics graphics, string text, System.Drawing.Font font, int maxWidth, System.Windows.Forms.TextFormatFlags flags);
public static int MeasureTextHeight (System.Drawing.Graphics graphics, string? text, System.Drawing.Font font, int maxWidth, System.Windows.Forms.TextFormatFlags flags);
static member MeasureTextHeight : System.Drawing.Graphics * string * System.Drawing.Font * int * System.Windows.Forms.TextFormatFlags -> int
Public Shared Function MeasureTextHeight (graphics As Graphics, text As String, font As Font, maxWidth As Integer, flags As TextFormatFlags) As Integer

Parameters

graphics
Graphics

The Graphics used to render the text.

text
String

The text to measure.

font
Font

The Font applied to the text.

maxWidth
Int32

The maximum width of the text.

flags
TextFormatFlags

A bitwise combination of TextFormatFlags values to apply to the text.

Returns

The height, in pixels, of the text.

Exceptions

graphics is null.

-or-

font is null.

maxWidth is less than 1.

flags is not a valid bitwise combination of TextFormatFlags values.

Remarks

If multiple lines are required and the specified formatting allows it, the height returned is the combined height of all lines.

See also

Applies to