RadioButtonRenderer.DrawRadioButton Método

Definición

Dibuja un control de botón de opción (también denominado botón de radio).

Sobrecargas

DrawRadioButton(Graphics, Point, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado.

DrawRadioButton(Graphics, Point, Rectangle, String, Font, Boolean, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado, con el texto especificado y con un rectángulo de foco opcional.

DrawRadioButton(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Boolean, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado, con el texto y el formato de texto especificados y con un rectángulo de foco opcional.

DrawRadioButton(Graphics, Point, Rectangle, String, Font, Image, Rectangle, Boolean, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado, con el texto y la imagen que se hayan especificado y con un rectángulo de foco opcional.

DrawRadioButton(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado, con el texto, el formato de texto y la imagen que se hayan especificado, y con un rectángulo de foco opcional.

DrawRadioButton(Graphics, Point, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado.

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

Parámetros

g
Graphics

Objeto Graphics que se utiliza para dibujar el botón de opción.

glyphLocation
Point

Estructura Point donde se dibuja el glifo del botón de opción.

state
RadioButtonState

Uno de los valores de RadioButtonState, que especifica el estado visual del botón de opción.

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á el botón de opción con el estilo visual actual. De lo contrario, este método dibujará el botón de opción con el estilo clásico de Windows.

Se aplica a

DrawRadioButton(Graphics, Point, Rectangle, String, Font, Boolean, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado, con el texto especificado y con un rectángulo de foco opcional.

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

Parámetros

g
Graphics

Objeto Graphics que se utiliza para dibujar el botón de opción.

glyphLocation
Point

Estructura Point donde se dibuja el glifo del botón de opción.

textBounds
Rectangle

Rectangle en el que se va a dibujar el radioButtonText.

radioButtonText
String

Objeto String que se va a dibujar con el botón de opción.

font
Font

Font que se va a aplicar a radioButtonText.

focused
Boolean

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

state
RadioButtonState

Uno de los valores de RadioButtonState, que especifica el estado visual del botón de opción.

Ejemplos

En el ejemplo de código siguiente se usa el DrawRadioButton(Graphics, Point, Rectangle, String, Font, Boolean, RadioButtonState) método en el método de OnPaint un control personalizado para dibujar un botón de opción en el estado determinado por la ubicación del puntero del mouse. Este ejemplo de código es parte de un ejemplo mayor proporcionado para la clase RadioButtonRenderer.

    // Draw the radio button in the current state.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        RadioButtonRenderer::DrawRadioButton(e->Graphics,
            ClientRectangle.Location, TextRectangle, this->Text,
            this->Font, clicked, state);
    }

    // Draw the radio button in the checked or unchecked state.
protected:
    virtual void OnMouseDown(MouseEventArgs^ e) override
    {
        __super::OnMouseDown(e);

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

    RadioButtonRenderer.DrawRadioButton(e.Graphics,
        ClientRectangle.Location, TextRectangle, this.Text,
        this.Font, clicked, state);
}

// Draw the radio button in the checked or unchecked state.
protected override void OnMouseDown(MouseEventArgs e)
{
    base.OnMouseDown(e);

    if (!clicked)
    {
        clicked = true;
        this.Text = "Clicked!";
        state = RadioButtonState.CheckedPressed;
        Invalidate();
    }
    else
    {
        clicked = false;
        this.Text = "Click here";
        state = RadioButtonState.UncheckedNormal;
        Invalidate();
    }
}
' Draw the radio button in the current state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)
    RadioButtonRenderer.DrawRadioButton(e.Graphics, _
        Me.ClientRectangle.Location, TextRectangle, Me.Text, _
        Me.Font, clicked, state)
End Sub

' Draw the radio button in the checked or unchecked state.
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
    MyBase.OnMouseDown(e)

    If Not clicked Then
        clicked = True
        Me.Text = "Clicked!"
        state = RadioButtonState.CheckedPressed
        Invalidate()
    Else
        clicked = False
        Me.Text = "Click here"
        state = RadioButtonState.UncheckedNormal
        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á el botón de opción con el estilo visual actual. De lo contrario, este método dibujará el botón de opción con el estilo clásico de Windows.

Se aplica a

DrawRadioButton(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Boolean, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado, con el texto y el formato de texto especificados y con un rectángulo de foco opcional.

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

Parámetros

g
Graphics

Objeto Graphics que se utiliza para dibujar el botón de opción.

glyphLocation
Point

Estructura Point donde se dibuja el glifo del botón de opción.

textBounds
Rectangle

Rectangle en el que se va a dibujar el radioButtonText.

radioButtonText
String

Objeto String que se va a dibujar con el botón de opción.

font
Font

Font que se va a aplicar a radioButtonText.

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
RadioButtonState

Uno de los valores de RadioButtonState, que especifica el estado visual del botón de opción.

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á el botón de opción con el estilo visual actual. De lo contrario, este método dibujará el botón de opción con el estilo clásico de Windows.

Se aplica a

DrawRadioButton(Graphics, Point, Rectangle, String, Font, Image, Rectangle, Boolean, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado, con el texto y la imagen que se hayan especificado y con un rectángulo de foco opcional.

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

Parámetros

g
Graphics

Objeto Graphics que se utiliza para dibujar el botón de opción.

glyphLocation
Point

Estructura Point donde se dibuja el glifo del botón de opción.

textBounds
Rectangle

Rectangle en el que se va a dibujar el radioButtonText.

radioButtonText
String

Objeto String que se va a dibujar con el botón de opción.

font
Font

Font que se va a aplicar a radioButtonText.

image
Image

Objeto Image que se va a dibujar con el botón de opción.

imageBounds
Rectangle

Rectangle en el que se va a dibujar el image.

focused
Boolean

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

state
RadioButtonState

Uno de los valores de RadioButtonState, que especifica el estado visual del botón de opción.

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á el botón de opción con el estilo visual actual. De lo contrario, este método dibujará el botón de opción con el estilo clásico de Windows.

Se aplica a

DrawRadioButton(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, RadioButtonState)

Dibuja un control de botón de opción (también denominado botón de radio) con el estado y en la ubicación que se hayan especificado, con el texto, el formato de texto y la imagen que se hayan especificado, y con un rectángulo de foco opcional.

public:
 static void DrawRadioButton(System::Drawing::Graphics ^ g, System::Drawing::Point glyphLocation, System::Drawing::Rectangle textBounds, System::String ^ radioButtonText, System::Drawing::Font ^ font, System::Windows::Forms::TextFormatFlags flags, System::Drawing::Image ^ image, System::Drawing::Rectangle imageBounds, bool focused, System::Windows::Forms::VisualStyles::RadioButtonState state);
public static void DrawRadioButton (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string radioButtonText, System.Drawing.Font font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.RadioButtonState state);
public static void DrawRadioButton (System.Drawing.Graphics g, System.Drawing.Point glyphLocation, System.Drawing.Rectangle textBounds, string? radioButtonText, System.Drawing.Font? font, System.Windows.Forms.TextFormatFlags flags, System.Drawing.Image image, System.Drawing.Rectangle imageBounds, bool focused, System.Windows.Forms.VisualStyles.RadioButtonState state);
static member DrawRadioButton : 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.RadioButtonState -> unit
Public Shared Sub DrawRadioButton (g As Graphics, glyphLocation As Point, textBounds As Rectangle, radioButtonText As String, font As Font, flags As TextFormatFlags, image As Image, imageBounds As Rectangle, focused As Boolean, state As RadioButtonState)

Parámetros

g
Graphics

Objeto Graphics que se utiliza para dibujar el botón de opción.

glyphLocation
Point

Estructura Point donde se dibuja el glifo del botón de opción.

textBounds
Rectangle

Rectangle en el que se va a dibujar el radioButtonText.

radioButtonText
String

Objeto String que se va a dibujar con el botón de opción.

font
Font

Font que se va a aplicar a radioButtonText.

flags
TextFormatFlags

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

image
Image

Objeto Image que se va a dibujar con el botón de opción.

imageBounds
Rectangle

Rectangle en el que se va a dibujar el image.

focused
Boolean

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

state
RadioButtonState

Uno de los valores de RadioButtonState, que especifica el estado visual del botón de opción.

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á el botón de opción con el estilo visual actual. De lo contrario, este método dibujará el botón de opción con el estilo clásico de Windows.

Se aplica a