Modifier

Partager via


DataGridViewCell.MeasureTextWidth Method

Definition

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

public:
 static int MeasureTextWidth(System::Drawing::Graphics ^ graphics, System::String ^ text, System::Drawing::Font ^ font, int maxHeight, System::Windows::Forms::TextFormatFlags flags);
public static int MeasureTextWidth (System.Drawing.Graphics graphics, string text, System.Drawing.Font font, int maxHeight, System.Windows.Forms.TextFormatFlags flags);
public static int MeasureTextWidth (System.Drawing.Graphics graphics, string? text, System.Drawing.Font font, int maxHeight, System.Windows.Forms.TextFormatFlags flags);
static member MeasureTextWidth : System.Drawing.Graphics * string * System.Drawing.Font * int * System.Windows.Forms.TextFormatFlags -> int
Public Shared Function MeasureTextWidth (graphics As Graphics, text As String, font As Font, maxHeight 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.

maxHeight
Int32

The maximum height of the text.

flags
TextFormatFlags

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

Returns

The width, in pixels, of the text.

Exceptions

graphics is null.

-or-

font is null.

maxHeight is less than 1.

flags is not a valid bitwise combination of TextFormatFlags values.

Applies to

See also