Share via


RadioButtonRenderer.DrawRadioButton Méthode

Définition

Dessine un contrôle de case d'option.

Surcharges

DrawRadioButton(Graphics, Point, RadioButtonState)

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés.

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

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés, avec le texte spécifié et avec un rectangle de focus facultatif.

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

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés, avec le texte et la mise en forme du texte spécifiés et avec un rectangle de focus facultatif.

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

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés, avec le texte et l'image spécifiés et avec un rectangle de focus facultatif.

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

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés, avec le texte, la mise en forme du texte et l'image spécifiés et avec un rectangle de focus facultatif.

DrawRadioButton(Graphics, Point, RadioButtonState)

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés.

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)

Paramètres

g
Graphics

Graphics utilisé pour dessiner la case d'option.

glyphLocation
Point

Point où dessiner le glyphe de la case d'option.

state
RadioButtonState

Une des valeurs RadioButtonState qui spécifie l'état visuel de la case d'option.

Remarques

Si les styles visuels sont activés dans le système d’exploitation et que les styles visuels sont appliqués à l’application actuelle, cette méthode dessine le bouton d’option avec le style visuel actuel. Sinon, cette méthode dessine le bouton d’option avec le style Windows classique.

S’applique à

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

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés, avec le texte spécifié et avec un rectangle de focus facultatif.

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)

Paramètres

g
Graphics

Graphics utilisé pour dessiner la case d'option.

glyphLocation
Point

Point où dessiner le glyphe de la case d'option.

textBounds
Rectangle

Rectangle dans lequel dessiner radioButtonText.

radioButtonText
String

String à dessiner avec la case d'option.

font
Font

Font à appliquer aux radioButtonText.

focused
Boolean

true pour dessiner un rectangle de focus ; sinon false.

state
RadioButtonState

Une des valeurs RadioButtonState qui spécifie l'état visuel de la case d'option.

Exemples

L’exemple de code suivant utilise la méthode dans la DrawRadioButton(Graphics, Point, Rectangle, String, Font, Boolean, RadioButtonState) méthode d’un OnPaint contrôle personnalisé pour dessiner un bouton d’option dans l’état déterminé par l’emplacement du pointeur de la souris. Cet exemple de code fait partie d’un exemple plus grand fourni pour la RadioButtonRenderer classe.

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

Remarques

Si les styles visuels sont activés dans le système d’exploitation et que les styles visuels sont appliqués à l’application actuelle, cette méthode dessine le bouton d’option avec le style visuel actuel. Sinon, cette méthode dessine le bouton d’option avec le style Windows classique.

S’applique à

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

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés, avec le texte et la mise en forme du texte spécifiés et avec un rectangle de focus facultatif.

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)

Paramètres

g
Graphics

Graphics utilisé pour dessiner la case d'option.

glyphLocation
Point

Point où dessiner le glyphe de la case d'option.

textBounds
Rectangle

Rectangle dans lequel dessiner radioButtonText.

radioButtonText
String

String à dessiner avec la case d'option.

font
Font

Font à appliquer aux radioButtonText.

flags
TextFormatFlags

Combinaison d'opérations de bits des valeurs TextFormatFlags.

focused
Boolean

true pour dessiner un rectangle de focus ; sinon false.

state
RadioButtonState

Une des valeurs RadioButtonState qui spécifie l'état visuel de la case d'option.

Remarques

Si les styles visuels sont activés dans le système d’exploitation et que les styles visuels sont appliqués à l’application actuelle, cette méthode dessine le bouton d’option avec le style visuel actuel. Sinon, cette méthode dessine le bouton d’option avec le style Windows classique.

S’applique à

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

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés, avec le texte et l'image spécifiés et avec un rectangle de focus facultatif.

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)

Paramètres

g
Graphics

Graphics utilisé pour dessiner la case d'option.

glyphLocation
Point

Point où dessiner le glyphe de la case d'option.

textBounds
Rectangle

Rectangle dans lequel dessiner radioButtonText.

radioButtonText
String

String à dessiner avec la case d'option.

font
Font

Font à appliquer aux radioButtonText.

image
Image

Image à dessiner avec la case d'option.

imageBounds
Rectangle

Rectangle dans lequel dessiner image.

focused
Boolean

true pour dessiner un rectangle de focus ; sinon false.

state
RadioButtonState

Une des valeurs RadioButtonState qui spécifie l'état visuel de la case d'option.

Remarques

Si les styles visuels sont activés dans le système d’exploitation et que les styles visuels sont appliqués à l’application actuelle, cette méthode dessine le bouton d’option avec le style visuel actuel. Sinon, cette méthode dessine le bouton d’option avec le style Windows classique.

S’applique à

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

Dessine un contrôle de case d'option dans l'état et à l'emplacement spécifiés, avec le texte, la mise en forme du texte et l'image spécifiés et avec un rectangle de focus facultatif.

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)

Paramètres

g
Graphics

Graphics utilisé pour dessiner la case d'option.

glyphLocation
Point

Point où dessiner le glyphe de la case d'option.

textBounds
Rectangle

Rectangle dans lequel dessiner radioButtonText.

radioButtonText
String

String à dessiner avec la case d'option.

font
Font

Font à appliquer aux radioButtonText.

flags
TextFormatFlags

Combinaison d'opérations de bits des valeurs TextFormatFlags.

image
Image

Image à dessiner avec la case d'option.

imageBounds
Rectangle

Rectangle dans lequel dessiner image.

focused
Boolean

true pour dessiner un rectangle de focus ; sinon false.

state
RadioButtonState

Une des valeurs RadioButtonState qui spécifie l'état visuel de la case d'option.

Remarques

Si les styles visuels sont activés dans le système d’exploitation et que les styles visuels sont appliqués à l’application actuelle, cette méthode dessine le bouton d’option avec le style visuel actuel. Sinon, cette méthode dessine le bouton d’option avec le style Windows classique.

S’applique à