DataGridViewCell.MeasureTextHeight 方法

定義

取得所指定文字的高度 (以像素為單位)。

多載

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

在指定的特性下,取得所指定文字的高度 (以像素為單位)。 而且也指出所需要的寬度是否大於指定的最大寬度。

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

在指定的特性下,取得所指定文字的高度 (以像素為單位)。

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

在指定的特性下,取得所指定文字的高度 (以像素為單位)。 而且也指出所需要的寬度是否大於指定的最大寬度。

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

參數

graphics
Graphics

用來呈現文字的 Graphics

text
String

要測量的文字。

font
Font

套用到文字的 Font

maxWidth
Int32

文字的最大寛度。

flags
TextFormatFlags

要套用至文字之 TextFormatFlags 值的位元組合。

widthTruncated
Boolean

如果所需要的文字大於 maxWidth,則設定為 true

傳回

文字的高度 (以像素為單位)。

例外狀況

graphicsnull

-或-

fontnull

maxWidth 小於 1。

flags 不是 TextFormatFlags 值的有效位元組合。

備註

如果需要多行,而且指定的格式允許它,傳回的高度會是所有線條的組合高度。

另請參閱

適用於

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

在指定的特性下,取得所指定文字的高度 (以像素為單位)。

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

參數

graphics
Graphics

用來呈現文字的 Graphics

text
String

要測量的文字。

font
Font

套用到文字的 Font

maxWidth
Int32

文字的最大寛度。

flags
TextFormatFlags

要套用至文字之 TextFormatFlags 值的位元組合。

傳回

文字的高度 (以像素為單位)。

例外狀況

graphicsnull

-或-

fontnull

maxWidth 小於 1。

flags 不是 TextFormatFlags 值的有效位元組合。

備註

如果需要多行,而且指定的格式允許它,傳回的高度會是所有線條的組合高度。

另請參閱

適用於