CheckBoxRenderer.DrawCheckBox Método

Definición

Dibuja un control de casilla.

Sobrecargas

DrawCheckBox(Graphics, Point, CheckBoxState)

Dibuja un control de casilla en el estado y la ubicación especificados.

DrawCheckBox(Graphics, Point, Rectangle, String, Font, Boolean, CheckBoxState)

Dibuja una casilla en el estado y la ubicación especificados, con el texto especificado y con un rectángulo de foco opcional.

DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Boolean, CheckBoxState)

Dibuja una casilla en el estado y la ubicación especificados, con el texto y el formato de texto especificados y con un rectángulo de foco opcional.

DrawCheckBox(Graphics, Point, Rectangle, String, Font, Image, Rectangle, Boolean, CheckBoxState)

Dibuja una casilla en el estado y la ubicación especificados, con el texto y la imagen especificados y con un rectángulo de foco opcional.

DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, CheckBoxState)

Dibuja una casilla en el estado y la ubicación especificados, con el texto, el formato de texto y la imagen especificados, y con un rectángulo de foco opcional.

DrawCheckBox(Graphics, Point, CheckBoxState)

Dibuja un control de casilla en el estado y la ubicación especificados.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, state As CheckBoxState)

Parámetros

g
Graphics

Graphics utilizado para dibujar la casilla.

glyphLocation
Point

Point en el que dibujar el glifo de casilla.

state
CheckBoxState

Uno de los valores de CheckBoxState que especifica el estado visual de la casilla.

Comentarios

Si los estilos visuales están habilitados en el sistema operativo y los estilos visuales se aplican a la aplicación actual, este método dibujará la casilla con el estilo visual actual. De lo contrario, dibujará la casilla con el estilo clásico Windows.

Se aplica a

DrawCheckBox(Graphics, Point, Rectangle, String, Font, Boolean, CheckBoxState)

Dibuja una casilla en el estado y la ubicación especificados, con el texto especificado y con un rectángulo de foco opcional.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Drawing::Rectangle textBounds, System::String ^ checkBoxText, System::Drawing::Font ^ font, bool focused, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string checkBoxText, System.Drawing.Font font, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string? checkBoxText, System.Drawing.Font? font, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Drawing.Rectangle * string * System.Drawing.Font * bool * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, textBounds As Rectangle, checkBoxText As String, font As Font, focused As Boolean, state As CheckBoxState)

Parámetros

g
Graphics

Graphics utilizado para dibujar la casilla.

glyphLocation
Point

Point en el que dibujar el glifo de casilla.

textBounds
Rectangle

Rectangle en el que se va a dibujar el checkBoxText.

checkBoxText
String

String que se va a dibujar con la casilla.

font
Font

Font que se va a aplicar a checkBoxText.

focused
Boolean

Es true para dibujar un rectángulo de foco; de lo contrario, es false.

state
CheckBoxState

Uno de los valores de CheckBoxState que especifica el estado visual de la casilla.

Comentarios

Si los estilos visuales están habilitados en el sistema operativo y los estilos visuales se aplican a la aplicación actual, este método dibujará la casilla con el estilo visual actual. De lo contrario, dibujará la casilla con el estilo clásico Windows.

Se aplica a

DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Boolean, CheckBoxState)

Dibuja una casilla en el estado y la ubicación especificados, con el texto y el formato de texto especificados y con un rectángulo de foco opcional.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Drawing::Rectangle textBounds, System::String ^ checkBoxText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, bool focused, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string checkBoxText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string? checkBoxText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.TextFormatFlags * bool * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, textBounds As Rectangle, checkBoxText As String, font As Font, flags As TextFormatFlags, focused As Boolean, state As CheckBoxState)

Parámetros

g
Graphics

Graphics utilizado para dibujar la casilla.

glyphLocation
Point

Point en el que dibujar el glifo de casilla.

textBounds
Rectangle

Rectangle en el que se va a dibujar el checkBoxText.

checkBoxText
String

String que se va a dibujar con la casilla.

font
Font

Font que se va a aplicar a checkBoxText.

flags
TextFormatFlags

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

focused
Boolean

Es true para dibujar un rectángulo de foco; de lo contrario, es false.

state
CheckBoxState

Uno de los valores de CheckBoxState que especifica el estado visual de la casilla.

Ejemplos

En el ejemplo de código siguiente se usa el DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Boolean, CheckBoxState) método en el método de OnPaint un control personalizado para dibujar una casilla en el estado determinado por la ubicación del puntero del mouse. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la CheckBoxRenderer clase .

// Draw the check box in the current state.
virtual void OnPaint(PaintEventArgs ^e) override
{
    Control::OnPaint(e);

    CheckBoxRenderer::DrawCheckBox(e->Graphics,
        ClientRectangle.Location, this->getTextRectangle(), this->Text,
        this->Font, TextFormatFlags::HorizontalCenter,
        clicked, state);
}


// Draw the check box in the checked or unchecked state, alternately.
virtual void OnMouseDown(MouseEventArgs ^e) override
{
    Control::OnMouseDown(e);

    if (!clicked)
    {
        clicked = true;
        this->Text = "Clicked!";
        state = CheckBoxState::CheckedPressed;
        Invalidate();
    }
    else
    {
        clicked = false;
        this->Text = "Click here";
        state = CheckBoxState::UncheckedNormal;
        Invalidate();
    }
}
// Draw the check box in the current state.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    CheckBoxRenderer.DrawCheckBox(e.Graphics,
        ClientRectangle.Location, TextRectangle, this.Text,
        this.Font, TextFormatFlags.HorizontalCenter,
        clicked, state);
}

// Draw the check box in the checked or unchecked state, alternately.
protected override void OnMouseDown(MouseEventArgs e)
{
    base.OnMouseDown(e);

    if (!clicked)
    {
        clicked = true;
        this.Text = "Clicked!";
        state = CheckBoxState.CheckedPressed;
        Invalidate();
    }
    else
    {
        clicked = false;
        this.Text = "Click here";
        state = CheckBoxState.UncheckedNormal;
        Invalidate();
    }
}
' Draw the check box in the current state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)
    CheckBoxRenderer.DrawCheckBox(e.Graphics, _
        Me.ClientRectangle.Location, TextRectangle, Me.Text, _
        Me.Font, TextFormatFlags.HorizontalCenter, _
        clicked, state)
End Sub

' Draw the check box in the checked or unchecked state, alternately.
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
    MyBase.OnMouseDown(e)
    If Not clicked Then
        With Me
            .clicked = True
            .Text = "Clicked!"
            .state = CheckBoxState.CheckedPressed
        End With
        Invalidate()
    Else
        With Me
            .clicked = False
            .Text = "Click here"
            .state = CheckBoxState.UncheckedNormal
        End With
        Invalidate()
    End If
End Sub

Comentarios

Si los estilos visuales están habilitados en el sistema operativo y los estilos visuales se aplican a la aplicación actual, este método dibujará la casilla con el estilo visual actual. De lo contrario, dibujará la casilla con el estilo clásico Windows.

Se aplica a

DrawCheckBox(Graphics, Point, Rectangle, String, Font, Image, Rectangle, Boolean, CheckBoxState)

Dibuja una casilla en el estado y la ubicación especificados, con el texto y la imagen especificados y con un rectángulo de foco opcional.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Drawing::Rectangle textBounds, System::String ^ checkBoxText, System::Drawing::Font ^ font, System::Drawing::Image ^ image, System::Drawing::Rectangle imageBounds, bool focused, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string checkBoxText, System.Drawing.Font font, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string? checkBoxText, System.Drawing.Font? font, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Drawing.Rectangle * string * System.Drawing.Font * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, textBounds As Rectangle, checkBoxText As String, font As Font, image As Image, imageBounds As Rectangle, focused As Boolean, state As CheckBoxState)

Parámetros

g
Graphics

Graphics utilizado para dibujar la casilla.

glyphLocation
Point

Point en el que dibujar el glifo de casilla.

textBounds
Rectangle

Rectangle en el que se va a dibujar el checkBoxText.

checkBoxText
String

String que se va a dibujar con la casilla.

font
Font

Font que se va a aplicar a checkBoxText.

image
Image

Image que se va a dibujar con la casilla.

imageBounds
Rectangle

Objeto Rectangle que representa las dimensiones de image.

focused
Boolean

Es true para dibujar un rectángulo de foco; de lo contrario, es false.

state
CheckBoxState

Uno de los valores de CheckBoxState que especifica el estado visual de la casilla.

Comentarios

Si los estilos visuales están habilitados en el sistema operativo y los estilos visuales se aplican a la aplicación actual, este método dibujará la casilla con el estilo visual actual. De lo contrario, dibujará la casilla con el estilo clásico Windows.

Se aplica a

DrawCheckBox(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, CheckBoxState)

Dibuja una casilla en el estado y la ubicación especificados, con el texto, el formato de texto y la imagen especificados, y con un rectángulo de foco opcional.

public:
 static void DrawCheckBox(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Drawing::Rectangle textBounds, System::String ^ checkBoxText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, System::Drawing::Image ^ image, System::Drawing::Rectangle imageBounds, bool focused, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string checkBoxText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
public static void DrawCheckBox (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string? checkBoxText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member DrawCheckBox : System.Drawing.Graphics * System.Drawing.Point * System.Drawing.Rectangle * string * System.Drawing.Font * System.Windows.Forms.TextFormatFlags * System.Drawing.Image * System.Drawing.Rectangle * bool * System.Windows.Forms.VisualStyles.CheckBoxState -> unit
Public Shared Sub DrawCheckBox (g As Graphics, glyphLocation As Point, textBounds As Rectangle, checkBoxText As String, font As Font, flags As TextFormatFlags, image As Image, imageBounds As Rectangle, focused As Boolean, state As CheckBoxState)

Parámetros

g
Graphics

Graphics utilizado para dibujar la casilla.

glyphLocation
Point

Point en el que dibujar el glifo de casilla.

textBounds
Rectangle

Rectangle en el que se va a dibujar el checkBoxText.

checkBoxText
String

String que se va a dibujar con la casilla.

font
Font

Font que se va a aplicar a checkBoxText.

flags
TextFormatFlags

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

image
Image

Image que se va a dibujar con la casilla.

imageBounds
Rectangle

Objeto Rectangle que representa las dimensiones de image.

focused
Boolean

Es true para dibujar un rectángulo de foco; de lo contrario, es false.

state
CheckBoxState

Uno de los valores de CheckBoxState que especifica el estado visual de la casilla.

Comentarios

Si los estilos visuales están habilitados en el sistema operativo y los estilos visuales se aplican a la aplicación actual, este método dibujará la casilla con el estilo visual actual. De lo contrario, dibujará la casilla con el estilo clásico Windows.

Se aplica a