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)
在指定的狀態和範圍中繪製文字方塊控制項。
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)
在指定的狀態和範圍中,使用指定的文字繪製文字方塊控制項。
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)
在指定的狀態和範圍中,使用指定的文字和文字範圍繪製文字方塊控制項。
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)
在指定的狀態和範圍中,使用指定的文字和文字格式繪製文字方塊控制項。
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)
在指定的狀態和範圍中,使用指定的文字、文字範圍和文字格式繪製文字方塊控制項。
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
回 。