DataGridViewCell.MeasureTextSize 方法

定義

在指定的特性下,取得所指定文字的高度和寬度。

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

參數

graphics
Graphics

用來呈現文字的 Graphics

text
String

要測量的文字。

font
Font

套用到文字的 Font

flags
TextFormatFlags

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

傳回

Size

Size,表示文字的高度和寬度。

例外狀況

graphicsnull

-或- fontnull

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

備註

如果需要多行且指定的格式允許,則傳回的大小會包含所有線條的組合高度。

適用於

另請參閱