Compartir por


TextBoxRenderer.DrawTextBox Método

Definición

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

Sobrecargas

Nombre Description
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 los límites de texto y 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)

Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs

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 utilizado para dibujar el cuadro de texto.

bounds
Rectangle

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

state
TextBoxState

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

Excepciones

El sistema operativo no admite estilos visuales.

O bien

El usuario deshabilita los estilos visuales en el sistema operativo.

O bien

Los estilos visuales no se aplican al área cliente de las ventanas de la 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)

Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs

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 utilizado para dibujar el cuadro de texto.

bounds
Rectangle

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

textBoxText
String

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

font
Font

que Font se va a aplicar a textBoxText.

state
TextBoxState

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

Excepciones

El sistema operativo no admite estilos visuales.

O bien

El usuario deshabilita los estilos visuales en el sistema operativo.

O bien

Los estilos visuales no se aplican al área cliente de las ventanas de la 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)

Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs

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

bounds
Rectangle

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

textBoxText
String

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

font
Font

que Font se va a aplicar a textBoxText.

textBounds
Rectangle

Rectangle que especifica los límites de textBoxText.

state
TextBoxState

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

Excepciones

El sistema operativo no admite estilos visuales.

O bien

El usuario deshabilita los estilos visuales en el sistema operativo.

O bien

Los estilos visuales no se aplican al área cliente de las ventanas de la 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)

Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs

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 utilizado para dibujar el cuadro de texto.

bounds
Rectangle

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

textBoxText
String

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

font
Font

que Font se va a aplicar a textBoxText.

flags
TextFormatFlags

Combinación bit a bit de los TextFormatFlags valores.

state
TextBoxState

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

Excepciones

El sistema operativo no admite estilos visuales.

O bien

El usuario deshabilita los estilos visuales en el sistema operativo.

O bien

Los estilos visuales no se aplican al área cliente de las ventanas de la 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)

Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs
Source:
TextBoxRenderer.cs

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 utilizado para dibujar el cuadro de texto.

bounds
Rectangle

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

textBoxText
String

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

font
Font

que Font 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 TextFormatFlags valores.

state
TextBoxState

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

Excepciones

El sistema operativo no admite estilos visuales.

O bien

El usuario deshabilita los estilos visuales en el sistema operativo.

O bien

Los estilos visuales no se aplican al área cliente de las ventanas de la 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 forma parte de un ejemplo más grande proporcionado para la TextBoxRenderer clase .

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