DataGridViewCell.MeasureTextWidth Methode

Definition

Ruft die Breite des angegebenen Texts in Pixeln ab, der den angegebenen Merkmalen entspricht.

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

Parameter

graphics
Graphics

Wird Graphics zum Rendern des Texts verwendet.

text
String

Der zu messende Text.

font
Font

Der Font auf den Text angewendete.

maxHeight
Int32

Die maximale Höhe des Texts.

flags
TextFormatFlags

Eine bitweise Kombination von TextFormatFlags Werten, die auf den Text angewendet werden sollen.

Gibt zurück

Die Breite des Texts in Pixel.

Ausnahmen

graphics ist null.

-oder-

font ist null.

maxHeight ist kleiner als 1.

flags ist keine gültige bitweise Kombination von TextFormatFlags Werten.

Gilt für:

Weitere Informationen