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

注解

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

适用于

另请参阅