DataGridViewCell.MeasureTextSize(Graphics, String, Font, TextFormatFlags) DataGridViewCell.MeasureTextSize(Graphics, String, Font, TextFormatFlags) DataGridViewCell.MeasureTextSize(Graphics, String, Font, TextFormatFlags) Method

定義

在指定的特性下,取得所指定文字的高度和寬度。Gets the height and width of the specified text given the specified characteristics.

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

參數

graphics
Graphics Graphics Graphics

用來呈現文字的 GraphicsThe Graphics used to render the text.

text
String String String

要測量的文字。The text to measure.

font
Font Font Font

套用到文字的 FontThe Font applied to the text.

flags
TextFormatFlags TextFormatFlags TextFormatFlags

要套用至文字之 TextFormatFlags 值的位元組合。A bitwise combination of TextFormatFlags values to apply to the text.

傳回

Size,表示文字的高度和寬度。A Size representing the height and width of the text.

例外狀況

graphicsnullgraphics is null.

-或--or- fontnullfont is null.

flags 不是 TextFormatFlags 值的有效位元組合。flags is not a valid bitwise combination of TextFormatFlags values.

備註

如果需要多行,且指定的格式允許,則傳回的大小會包含所有線條的結合高度。If multiple lines are required and the specified formatting allows it, the size returned includes the combined height of all lines.

適用於

另請參閱