DataGridViewCell.MeasureTextPreferredSize 方法

定義

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

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

參數

graphics
Graphics

用來呈現文字的 Graphics

text
String

要測量的文字。

font
Font

套用到文字的 Font

maxRatio
Single

文字區塊的最大寬度與高度比。

flags
TextFormatFlags

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

傳回

Size

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

例外狀況

graphicsnull

-或- fontnull

maxRatio 小於或等於 0。

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

備註

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

適用於

另請參閱