DataGridViewCell.MeasureTextHeight 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得指定文字的高度(像素數)。
多載
| 名稱 | Description |
|---|---|
| MeasureTextHeight(Graphics, String, Font, Int32, TextFormatFlags, Boolean) |
取得指定文字的高度(像素),根據指定特性。 同時也表示所需寬度是否大於規定的最大寬度。 |
| MeasureTextHeight(Graphics, String, Font, Int32, TextFormatFlags) |
取得指定文字的高度(像素),根據指定特性。 |
MeasureTextHeight(Graphics, String, Font, Int32, TextFormatFlags, Boolean)
取得指定文字的高度(像素),根據指定特性。 同時也表示所需寬度是否大於規定的最大寬度。
public:
static int MeasureTextHeight(System::Drawing::Graphics ^ graphics, System::String ^ text, System::Drawing::Font ^ font, int maxWidth, System::Windows::Forms::TextFormatFlags flags, [Runtime::InteropServices::Out] bool % widthTruncated);
public static int MeasureTextHeight(System.Drawing.Graphics graphics, string text, System.Drawing.Font font, int maxWidth, System.Windows.Forms.TextFormatFlags flags, out bool widthTruncated);
public static int MeasureTextHeight(System.Drawing.Graphics graphics, string? text, System.Drawing.Font font, int maxWidth, System.Windows.Forms.TextFormatFlags flags, out bool widthTruncated);
static member MeasureTextHeight : System.Drawing.Graphics * string * System.Drawing.Font * int * System.Windows.Forms.TextFormatFlags * bool -> int
Public Shared Function MeasureTextHeight (graphics As Graphics, text As String, font As Font, maxWidth As Integer, flags As TextFormatFlags, ByRef widthTruncated As Boolean) As Integer
參數
- text
- String
要衡量的文字。
- maxWidth
- Int32
文字的最大寬度。
- flags
- TextFormatFlags
一個位元組合 TextFormatFlags 的數值,用來套用在文字上。
- widthTruncated
- Boolean
若要求的文字寬度大於 true,則設為 maxWidth 。
傳回
文字的高度,以像素為單位。
例外狀況
maxWidth 小於1。
flags 不是有效的位元組合 TextFormatFlags 。
備註
若需多行且格式允許,回傳的高度為所有行的總高度。
另請參閱
適用於
MeasureTextHeight(Graphics, String, Font, Int32, TextFormatFlags)
取得指定文字的高度(像素),根據指定特性。
public:
static int MeasureTextHeight(System::Drawing::Graphics ^ graphics, System::String ^ text, System::Drawing::Font ^ font, int maxWidth, System::Windows::Forms::TextFormatFlags flags);
public static int MeasureTextHeight(System.Drawing.Graphics graphics, string text, System.Drawing.Font font, int maxWidth, System.Windows.Forms.TextFormatFlags flags);
public static int MeasureTextHeight(System.Drawing.Graphics graphics, string? text, System.Drawing.Font font, int maxWidth, System.Windows.Forms.TextFormatFlags flags);
static member MeasureTextHeight : System.Drawing.Graphics * string * System.Drawing.Font * int * System.Windows.Forms.TextFormatFlags -> int
Public Shared Function MeasureTextHeight (graphics As Graphics, text As String, font As Font, maxWidth As Integer, flags As TextFormatFlags) As Integer
參數
- text
- String
要衡量的文字。
- maxWidth
- Int32
文字的最大寬度。
- flags
- TextFormatFlags
一個位元組合 TextFormatFlags 的數值,用來套用在文字上。
傳回
文字的高度,以像素為單位。
例外狀況
maxWidth 小於1。
flags 不是有效的位元組合 TextFormatFlags 。
備註
若需多行且格式允許,回傳的高度為所有行的總高度。