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 值的有效按位组合。

注解

如果需要多行并且指定格式允许,则返回的大小包括所有行的组合高度。

适用于

另请参阅