TextBoxRenderer.DrawTextBox 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
绘制具有操作系统的当前视觉样式的文本框控件。
重载
DrawTextBox(Graphics, Rectangle, TextBoxState) |
绘制具有指定状态和边界的文本框控件。 |
DrawTextBox(Graphics, Rectangle, String, Font, TextBoxState) |
绘制具有指定的状态和边界以及指定的文本的文本框控件。 |
DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextBoxState) |
绘制具有指定的状态和边界以及指定的文本和文本边界的文本框控件。 |
DrawTextBox(Graphics, Rectangle, String, Font, TextFormatFlags, TextBoxState) |
绘制具有指定的状态和边界以及指定的文本和文本格式的文本框控件。 |
DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, TextBoxState) |
绘制具有指定的状态和边界以及指定的文本、文本边界和文本格式的文本框控件。 |
DrawTextBox(Graphics, Rectangle, TextBoxState)
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
绘制具有指定状态和边界的文本框控件。
public:
static void DrawTextBox(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::Windows::Forms::VisualStyles::TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.VisualStyles.TextBoxState state);
static member DrawTextBox : System.Drawing.Graphics * System.Drawing.Rectangle * System.Windows.Forms.VisualStyles.TextBoxState -> unit
Public Shared Sub DrawTextBox (g As Graphics, bounds As Rectangle, state As TextBoxState)
参数
- state
- TextBoxState
TextBoxState 值之一,它指定文本框的可视状态。
例外
注解
在调用此方法之前,应验证 属性是否 IsSupported 返回 true
。
适用于
DrawTextBox(Graphics, Rectangle, String, Font, TextBoxState)
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
绘制具有指定的状态和边界以及指定的文本的文本框控件。
public:
static void DrawTextBox(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ textBoxText, System::Drawing::Font ^ font, System::Windows::Forms::VisualStyles::TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string textBoxText, System.Drawing.Font font, System.Windows.Forms.VisualStyles.TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? textBoxText, System.Drawing.Font? font, System.Windows.Forms.VisualStyles.TextBoxState state);
static member DrawTextBox : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.VisualStyles.TextBoxState -> unit
Public Shared Sub DrawTextBox (g As Graphics, bounds As Rectangle, textBoxText As String, font As Font, state As TextBoxState)
参数
- state
- TextBoxState
TextBoxState 值之一,它指定文本框的可视状态。
例外
注解
在调用此方法之前,应验证 属性是否 IsSupported 返回 true
。
适用于
DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextBoxState)
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
绘制具有指定的状态和边界以及指定的文本和文本边界的文本框控件。
public:
static void DrawTextBox(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ textBoxText, System::Drawing::Font ^ font, System::Drawing::Rectangle textBounds, System::Windows::Forms::VisualStyles::TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string textBoxText, System.Drawing.Font font, System.Drawing.Rectangle textBounds, System.Windows.Forms.VisualStyles.TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? textBoxText, System.Drawing.Font? font, System.Drawing.Rectangle textBounds, System.Windows.Forms.VisualStyles.TextBoxState state);
static member DrawTextBox : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Drawing.Rectangle * System.Windows.Forms.VisualStyles.TextBoxState -> unit
Public Shared Sub DrawTextBox (g As Graphics, bounds As Rectangle, textBoxText As String, font As Font, textBounds As Rectangle, state As TextBoxState)
参数
- state
- TextBoxState
TextBoxState 值之一,它指定文本框的可视状态。
例外
注解
在调用此方法之前,应验证 属性是否 IsSupported 返回 true
。
适用于
DrawTextBox(Graphics, Rectangle, String, Font, TextFormatFlags, TextBoxState)
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
绘制具有指定的状态和边界以及指定的文本和文本格式的文本框控件。
public:
static void DrawTextBox(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ textBoxText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, System::Windows::Forms::VisualStyles::TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string textBoxText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, System.Windows.Forms.VisualStyles.TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? textBoxText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, System.Windows.Forms.VisualStyles.TextBoxState state);
static member DrawTextBox : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.TextFormatFlags * System.Windows.Forms.VisualStyles.TextBoxState -> unit
Public Shared Sub DrawTextBox (g As Graphics, bounds As Rectangle, textBoxText As String, font As Font, flags As TextFormatFlags, state As TextBoxState)
参数
- flags
- TextFormatFlags
TextFormatFlags 值的按位组合。
- state
- TextBoxState
TextBoxState 值之一,它指定文本框的可视状态。
例外
注解
在调用此方法之前,应验证 属性是否 IsSupported 返回 true
。
适用于
DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, TextBoxState)
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
- Source:
- TextBoxRenderer.cs
绘制具有指定的状态和边界以及指定的文本、文本边界和文本格式的文本框控件。
public:
static void DrawTextBox(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds, System::String ^ textBoxText, System::Drawing::Font ^ font, System::Drawing::Rectangle textBounds, System::Windows::Forms::TextFormatFlags flags, System::Windows::Forms::VisualStyles::TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string textBoxText, System.Drawing.Font font, System.Drawing.Rectangle textBounds, System.Windows.Forms.TextFormatFlags flags, System.Windows.Forms.VisualStyles.TextBoxState state);
public static void DrawTextBox (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, string? textBoxText, System.Drawing.Font? font, System.Drawing.Rectangle textBounds, System.Windows.Forms.TextFormatFlags flags, System.Windows.Forms.VisualStyles.TextBoxState state);
static member DrawTextBox : System.Drawing.Graphics * System.Drawing.Rectangle * string * System.Drawing.Font * System.Drawing.Rectangle * System.Windows.Forms.TextFormatFlags * System.Windows.Forms.VisualStyles.TextBoxState -> unit
Public Shared Sub DrawTextBox (g As Graphics, bounds As Rectangle, textBoxText As String, font As Font, textBounds As Rectangle, flags As TextFormatFlags, state As TextBoxState)
参数
- flags
- TextFormatFlags
TextFormatFlags 值的按位组合。
- state
- TextBoxState
TextBoxState 值之一,它指定文本框的可视状态。
例外
示例
下面的代码示例演示如何在自定义控件的 OnPaint 方法中使用 DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, TextBoxState) 方法来绘制文本框。 此代码示例是为 TextBoxRenderer 类提供的一个更大示例的一部分。
// Use DrawText with the current TextFormatFlags.
protected:
virtual void OnPaint(PaintEventArgs^ e) override
{
__super::OnPaint(e);
if (TextBoxRenderer::IsSupported)
{
TextBoxRenderer::DrawTextBox(e->Graphics, textBorder, this->Text,
this->Font, textRectangle, textFlags, TextBoxState::Normal);
this->Parent->Text = "CustomTextBox Enabled";
}
else
{
this->Parent->Text = "CustomTextBox Disabled";
}
}
// Use DrawText with the current TextFormatFlags.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (TextBoxRenderer.IsSupported)
{
TextBoxRenderer.DrawTextBox(e.Graphics, textBorder, this.Text,
this.Font, textRectangle, textFlags, TextBoxState.Normal);
this.Parent.Text = "CustomTextBox Enabled";
}
else
{
this.Parent.Text = "CustomTextBox Disabled";
}
}
' Use DrawText with the current TextFormatFlags.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
MyBase.OnPaint(e)
If TextBoxRenderer.IsSupported Then
TextBoxRenderer.DrawTextBox(e.Graphics, textBorder, Me.Text, _
Me.Font, textRectangle, textFlags, TextBoxState.Normal)
Me.Parent.Text = "CustomTextBox Enabled"
Else
Me.Parent.Text = "CustomTextBox Disabled"
End If
End Sub
注解
在调用此方法之前,应验证 属性是否 IsSupported 返回 true
。