TextBoxRenderer.DrawTextBox Método

Definição

Desenha um controle de caixa de texto com o estilo visual atual do sistema operacional.

Sobrecargas

DrawTextBox(Graphics, Rectangle, TextBoxState)

Desenha um controle de caixa de texto no estado e nos limites especificados.

DrawTextBox(Graphics, Rectangle, String, Font, TextBoxState)

Desenha um controle de caixa de texto no estado e limites especificados e com o texto especificado.

DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextBoxState)

Desenha um controle de caixa de texto no estado e limites especificados e com o texto e os limites de texto especificados.

DrawTextBox(Graphics, Rectangle, String, Font, TextFormatFlags, TextBoxState)

Desenha um controle de caixa de texto no estado e limites especificados e com o texto e a formatação de texto especificados.

DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, TextBoxState)

Desenha um controle de caixa de texto no estado e limites especificados e com o texto, os limites de texto e a formatação de texto especificados.

DrawTextBox(Graphics, Rectangle, TextBoxState)

Desenha um controle de caixa de texto no estado e nos limites especificados.

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)

Parâmetros

g
Graphics

O Graphics usado para desenhar a caixa de texto.

bounds
Rectangle

O Rectangle que especifica os limites da caixa de texto.

state
TextBoxState

Um dos valores de TextBoxState que especifica o estado visual da caixa de texto.

Exceções

O sistema operacional não dá suporte a estilos visuais.

- ou -

Os estilos visuais estão desabilitados pelo usuário no sistema operacional.

- ou -

Os estilos visuais não são aplicados à área de cliente das janelas de aplicativos.

Comentários

Antes de chamar esse método, você deve verificar se a IsSupported propriedade retorna true.

Aplica-se a

DrawTextBox(Graphics, Rectangle, String, Font, TextBoxState)

Desenha um controle de caixa de texto no estado e limites especificados e com o texto especificado.

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)

Parâmetros

g
Graphics

O Graphics usado para desenhar a caixa de texto.

bounds
Rectangle

O Rectangle que especifica os limites da caixa de texto.

textBoxText
String

O String para desenhar na caixa de texto.

font
Font

O Font a ser aplicado a textBoxText.

state
TextBoxState

Um dos valores de TextBoxState que especifica o estado visual da caixa de texto.

Exceções

O sistema operacional não dá suporte a estilos visuais.

- ou -

Os estilos visuais estão desabilitados pelo usuário no sistema operacional.

- ou -

Os estilos visuais não são aplicados à área de cliente das janelas de aplicativos.

Comentários

Antes de chamar esse método, você deve verificar se a IsSupported propriedade retorna true.

Aplica-se a

DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextBoxState)

Desenha um controle de caixa de texto no estado e limites especificados e com o texto e os limites de texto especificados.

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)

Parâmetros

g
Graphics

O Graphics usado para desenhar a caixa de texto.

bounds
Rectangle

O Rectangle que especifica os limites da caixa de texto.

textBoxText
String

O String para desenhar na caixa de texto.

font
Font

O Font a ser aplicado a textBoxText.

textBounds
Rectangle

O Rectangle que especifica os limites da textBoxText.

state
TextBoxState

Um dos valores de TextBoxState que especifica o estado visual da caixa de texto.

Exceções

O sistema operacional não dá suporte a estilos visuais.

- ou -

Os estilos visuais estão desabilitados pelo usuário no sistema operacional.

- ou -

Os estilos visuais não são aplicados à área de cliente das janelas de aplicativos.

Comentários

Antes de chamar esse método, você deve verificar se a IsSupported propriedade retorna true.

Aplica-se a

DrawTextBox(Graphics, Rectangle, String, Font, TextFormatFlags, TextBoxState)

Desenha um controle de caixa de texto no estado e limites especificados e com o texto e a formatação de texto especificados.

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)

Parâmetros

g
Graphics

O Graphics usado para desenhar a caixa de texto.

bounds
Rectangle

O Rectangle que especifica os limites da caixa de texto.

textBoxText
String

O String para desenhar na caixa de texto.

font
Font

O Font a ser aplicado a textBoxText.

flags
TextFormatFlags

Uma combinação bit a bit dos valores TextFormatFlags.

state
TextBoxState

Um dos valores de TextBoxState que especifica o estado visual da caixa de texto.

Exceções

O sistema operacional não dá suporte a estilos visuais.

- ou -

Os estilos visuais estão desabilitados pelo usuário no sistema operacional.

- ou -

Os estilos visuais não são aplicados à área de cliente das janelas de aplicativos.

Comentários

Antes de chamar esse método, você deve verificar se a IsSupported propriedade retorna true.

Aplica-se a

DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, TextBoxState)

Desenha um controle de caixa de texto no estado e limites especificados e com o texto, os limites de texto e a formatação de texto especificados.

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)

Parâmetros

g
Graphics

O Graphics usado para desenhar a caixa de texto.

bounds
Rectangle

O Rectangle que especifica os limites da caixa de texto.

textBoxText
String

O String para desenhar na caixa de texto.

font
Font

O Font a ser aplicado a textBoxText.

textBounds
Rectangle

O Rectangle que especifica os limites da textBoxText.

flags
TextFormatFlags

Uma combinação bit a bit dos valores TextFormatFlags.

state
TextBoxState

Um dos valores de TextBoxState que especifica o estado visual da caixa de texto.

Exceções

O sistema operacional não dá suporte a estilos visuais.

- ou -

Os estilos visuais estão desabilitados pelo usuário no sistema operacional.

- ou -

Os estilos visuais não são aplicados à área de cliente das janelas de aplicativos.

Exemplos

O exemplo de código a seguir demonstra como usar o DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, TextBoxState) método no método de OnPaint um controle personalizado para desenhar uma caixa de texto. Este exemplo de código faz parte de um exemplo maior fornecido para a TextBoxRenderer classe.

    // 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

Comentários

Antes de chamar esse método, você deve verificar se a IsSupported propriedade retorna true.

Aplica-se a