DataGridViewCell.MeasureTextWidth 方法

定義

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

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

參數

graphics
Graphics

用來呈現文字的 Graphics

text
String

要測量的文字。

font
Font

套用到文字的 Font

maxHeight
Int32

文字的最大高度。

flags
TextFormatFlags

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

傳回

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

例外狀況

graphicsnull

-或-

fontnull

maxHeight 小於 1。

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

適用於

另請參閱