TextBoxRenderer.DrawTextBox Método

Definición

Dibuja un control de cuadro de texto con el estilo visual actual del sistema operativo.

Sobrecargas

DrawTextBox(Graphics, Rectangle, TextBoxState)

Dibuja un control de cuadro de texto en el estado y los límites especificados.

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

Dibuja un control de cuadro de texto en el estado y los límites especificados, y con el texto especificado.

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

Dibuja un control de cuadro de texto en el estado y los límites especificados, y con el texto y los límites de texto especificados.

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

Dibuja un control de cuadro de texto en el estado y los límites especificados, y con el texto y el formato de texto especificados.

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

Dibuja un control de cuadro de texto en el estado y los límites especificados, y con el texto, los límites de texto y el formato de texto especificados.

DrawTextBox(Graphics, Rectangle, TextBoxState)

Dibuja un control de cuadro de texto en el estado y los límites 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

Graphics que se utiliza para dibujar el cuadro de texto.

bounds
Rectangle

Rectangle que especifica los límites del cuadro de texto.

state
TextBoxState

Uno de los valores de TextBoxState que especifica el estado visual del cuadro de texto.

Excepciones

El sistema operativo no admite estilos visuales.

o bien

El usuario ha deshabilitado los estilos visuales en el sistema operativo.

o bien

Los estilos visuales no se aplican al área de cliente de las ventanas de aplicación.

Comentarios

Antes de llamar a este método, debe comprobar que la IsSupported propiedad devuelve true.

Se aplica a

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

Dibuja un control de cuadro de texto en el estado y los límites especificados, y con el 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

Graphics que se utiliza para dibujar el cuadro de texto.

bounds
Rectangle

Rectangle que especifica los límites del cuadro de texto.

textBoxText
String

String que se va a dibujar en el cuadro de texto.

font
Font

Font que se va a aplicar a textBoxText.

state
TextBoxState

Uno de los valores de TextBoxState que especifica el estado visual del cuadro de texto.

Excepciones

El sistema operativo no admite estilos visuales.

o bien

El usuario ha deshabilitado los estilos visuales en el sistema operativo.

o bien

Los estilos visuales no se aplican al área de cliente de las ventanas de aplicación.

Comentarios

Antes de llamar a este método, debe comprobar que la IsSupported propiedad devuelve true.

Se aplica a

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

Dibuja un control de cuadro de texto en el estado y los límites especificados, y con el texto y los límites 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

Graphics que se utiliza para dibujar el cuadro de texto.

bounds
Rectangle

Rectangle que especifica los límites del cuadro de texto.

textBoxText
String

String que se va a dibujar en el cuadro de texto.

font
Font

Font que se va a aplicar a textBoxText.

textBounds
Rectangle

Rectangle que especifica los límites de textBoxText.

state
TextBoxState

Uno de los valores de TextBoxState que especifica el estado visual del cuadro de texto.

Excepciones

El sistema operativo no admite estilos visuales.

o bien

El usuario ha deshabilitado los estilos visuales en el sistema operativo.

o bien

Los estilos visuales no se aplican al área de cliente de las ventanas de aplicación.

Comentarios

Antes de llamar a este método, debe comprobar que la IsSupported propiedad devuelve true.

Se aplica a

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

Dibuja un control de cuadro de texto en el estado y los límites especificados, y con el texto y el formato 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

Graphics que se utiliza para dibujar el cuadro de texto.

bounds
Rectangle

Rectangle que especifica los límites del cuadro de texto.

textBoxText
String

String que se va a dibujar en el cuadro de texto.

font
Font

Font que se va a aplicar a textBoxText.

flags
TextFormatFlags

Combinación bit a bit de los valores de TextFormatFlags.

state
TextBoxState

Uno de los valores de TextBoxState que especifica el estado visual del cuadro de texto.

Excepciones

El sistema operativo no admite estilos visuales.

o bien

El usuario ha deshabilitado los estilos visuales en el sistema operativo.

o bien

Los estilos visuales no se aplican al área de cliente de las ventanas de aplicación.

Comentarios

Antes de llamar a este método, debe comprobar que la IsSupported propiedad devuelve true.

Se aplica a

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

Dibuja un control de cuadro de texto en el estado y los límites especificados, y con el texto, los límites de texto y el formato 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

Graphics que se utiliza para dibujar el cuadro de texto.

bounds
Rectangle

Rectangle que especifica los límites del cuadro de texto.

textBoxText
String

String que se va a dibujar en el cuadro de texto.

font
Font

Font que se va a aplicar a textBoxText.

textBounds
Rectangle

Rectangle que especifica los límites de textBoxText.

flags
TextFormatFlags

Combinación bit a bit de los valores de TextFormatFlags.

state
TextBoxState

Uno de los valores de TextBoxState que especifica el estado visual del cuadro de texto.

Excepciones

El sistema operativo no admite estilos visuales.

o bien

El usuario ha deshabilitado los estilos visuales en el sistema operativo.

o bien

Los estilos visuales no se aplican al área de cliente de las ventanas de aplicación.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el DrawTextBox(Graphics, Rectangle, String, Font, Rectangle, TextFormatFlags, TextBoxState) método en el método de OnPaint un control personalizado para dibujar un cuadro de texto. Este ejemplo de código es parte de un ejemplo mayor proporcionado para la clase 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

Comentarios

Antes de llamar a este método, debe comprobar que la IsSupported propiedad devuelve true.

Se aplica a