VisualStyleRenderer.GetTextExtent 方法

定义

返回指定的字符串在用当前视觉样式元素的字体绘制时的大小和位置。Returns the size and location of the specified string when drawn with the font of the current visual style element.

重载

GetTextExtent(IDeviceContext, String, TextFormatFlags)

返回指定的字符串在用当前视觉样式元素的字体绘制时的大小和位置。Returns the size and location of the specified string when drawn with the font of the current visual style element.

GetTextExtent(IDeviceContext, Rectangle, String, TextFormatFlags)

返回指定的字符串当用当前视觉样式元素的字体在指定的初始边框内绘制时的大小和位置。Returns the size and location of the specified string when drawn with the font of the current visual style element within the specified initial bounding rectangle.

GetTextExtent(IDeviceContext, String, TextFormatFlags)

返回指定的字符串在用当前视觉样式元素的字体绘制时的大小和位置。Returns the size and location of the specified string when drawn with the font of the current visual style element.

public:
 System::Drawing::Rectangle GetTextExtent(System::Drawing::IDeviceContext ^ dc, System::String ^ textToDraw, System::Windows::Forms::TextFormatFlags flags);
public System.Drawing.Rectangle GetTextExtent (System.Drawing.IDeviceContext dc, string textToDraw, System.Windows.Forms.TextFormatFlags flags);
member this.GetTextExtent : System.Drawing.IDeviceContext * string * System.Windows.Forms.TextFormatFlags -> System.Drawing.Rectangle
Public Function GetTextExtent (dc As IDeviceContext, textToDraw As String, flags As TextFormatFlags) As Rectangle

参数

dc
IDeviceContext

此操作将使用的 IDeviceContextThe IDeviceContext this operation will use.

textToDraw
String

要度量的字符串。The string to measure.

flags
TextFormatFlags

TextFormatFlags 值的按位组合。A bitwise combination of the TextFormatFlags values.

返回

一个 Rectangle,它包含适应呈现的文本所需的区域。A Rectangle that contains the area required to fit the rendered text.

异常

dcnulldc is null.

GetTextExtent(IDeviceContext, Rectangle, String, TextFormatFlags)

返回指定的字符串当用当前视觉样式元素的字体在指定的初始边框内绘制时的大小和位置。Returns the size and location of the specified string when drawn with the font of the current visual style element within the specified initial bounding rectangle.

public:
 System::Drawing::Rectangle GetTextExtent(System::Drawing::IDeviceContext ^ dc, System::Drawing::Rectangle bounds, System::String ^ textToDraw, System::Windows::Forms::TextFormatFlags flags);
public System.Drawing.Rectangle GetTextExtent (System.Drawing.IDeviceContext dc, System.Drawing.Rectangle bounds, string textToDraw, System.Windows.Forms.TextFormatFlags flags);
member this.GetTextExtent : System.Drawing.IDeviceContext * System.Drawing.Rectangle * string * System.Windows.Forms.TextFormatFlags -> System.Drawing.Rectangle
Public Function GetTextExtent (dc As IDeviceContext, bounds As Rectangle, textToDraw As String, flags As TextFormatFlags) As Rectangle

参数

dc
IDeviceContext

此操作将使用的 IDeviceContextThe IDeviceContext this operation will use.

bounds
Rectangle

一个 Rectangle,用于控制文本的流和换行。A Rectangle used to control the flow and wrapping of the text.

textToDraw
String

要度量的字符串。The string to measure.

flags
TextFormatFlags

TextFormatFlags 值的按位组合。A bitwise combination of the TextFormatFlags values.

返回

一个 Rectangle,它包含适应呈现的文本所需的区域。A Rectangle that contains the area required to fit the rendered text.

异常

dcnulldc is null.

适用于