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

适用于

另请参阅