Share via


RadioButtonRenderer.DrawRadioButton Metode

Definisi

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio).

Overload

DrawRadioButton(Graphics, Point, RadioButtonState)

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan.

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

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan, dengan teks yang ditentukan, dan dengan persegi panjang fokus opsional.

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

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan, dengan pemformatan teks dan teks yang ditentukan, dan dengan persegi panjang fokus opsional.

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

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan, dengan teks dan gambar yang ditentukan, dan dengan persegi panjang fokus opsional.

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

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan; dengan teks, pemformatan teks, dan gambar yang ditentukan; dan dengan persegi panjang fokus opsional.

DrawRadioButton(Graphics, Point, RadioButtonState)

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar tombol opsi.

glyphLocation
Point

tombol Point untuk menggambar opsi glyph at.

state
RadioButtonState

Salah RadioButtonState satu nilai yang menentukan status visual tombol opsi.

Keterangan

Jika gaya visual diaktifkan dalam sistem operasi dan gaya visual diterapkan ke aplikasi saat ini, metode ini akan menggambar tombol opsi dengan gaya visual saat ini. Jika tidak, metode ini akan menggambar tombol opsi dengan gaya Windows klasik.

Berlaku untuk

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

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan, dengan teks yang ditentukan, dan dengan persegi panjang fokus opsional.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar tombol opsi.

glyphLocation
Point

tombol Point untuk menggambar opsi glyph at.

textBounds
Rectangle

Yang Rectangle akan ditarik radioButtonText .

radioButtonText
String

untuk String menggambar dengan tombol opsi.

font
Font

Font untuk diterapkan ke radioButtonText.

focused
Boolean

true untuk menggambar persegi panjang fokus; jika tidak, false.

state
RadioButtonState

Salah RadioButtonState satu nilai yang menentukan status visual tombol opsi.

Contoh

Contoh kode berikut menggunakan DrawRadioButton(Graphics, Point, Rectangle, String, Font, Boolean, RadioButtonState) metode dalam metode kontrol OnPaint kustom untuk menggambar tombol opsi dalam status yang ditentukan oleh lokasi penunjuk mouse. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk RadioButtonRenderer kelas .

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

Keterangan

Jika gaya visual diaktifkan dalam sistem operasi dan gaya visual diterapkan ke aplikasi saat ini, metode ini akan menggambar tombol opsi dengan gaya visual saat ini. Jika tidak, metode ini akan menggambar tombol opsi dengan gaya Windows klasik.

Berlaku untuk

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

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan, dengan pemformatan teks dan teks yang ditentukan, dan dengan persegi panjang fokus opsional.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar tombol opsi.

glyphLocation
Point

tombol Point untuk menggambar opsi glyph at.

textBounds
Rectangle

Yang Rectangle akan ditarik radioButtonText .

radioButtonText
String

untuk String menggambar dengan tombol opsi.

font
Font

Font untuk diterapkan ke radioButtonText.

flags
TextFormatFlags

Kombinasi bitwise dari TextFormatFlags nilai.

focused
Boolean

true untuk menggambar persegi panjang fokus; jika tidak, false.

state
RadioButtonState

Salah RadioButtonState satu nilai yang menentukan status visual tombol opsi.

Keterangan

Jika gaya visual diaktifkan dalam sistem operasi dan gaya visual diterapkan ke aplikasi saat ini, metode ini akan menggambar tombol opsi dengan gaya visual saat ini. Jika tidak, metode ini akan menggambar tombol opsi dengan gaya Windows klasik.

Berlaku untuk

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

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan, dengan teks dan gambar yang ditentukan, dan dengan persegi panjang fokus opsional.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar tombol opsi.

glyphLocation
Point

tombol Point untuk menggambar opsi glyph at.

textBounds
Rectangle

Yang Rectangle akan ditarik radioButtonText .

radioButtonText
String

untuk String menggambar dengan tombol opsi.

font
Font

Font untuk diterapkan ke radioButtonText.

image
Image

untuk Image menggambar dengan tombol opsi.

imageBounds
Rectangle

Yang Rectangle akan ditarik image .

focused
Boolean

true untuk menggambar persegi panjang fokus; jika tidak, false.

state
RadioButtonState

Salah RadioButtonState satu nilai yang menentukan status visual tombol opsi.

Keterangan

Jika gaya visual diaktifkan dalam sistem operasi dan gaya visual diterapkan ke aplikasi saat ini, metode ini akan menggambar tombol opsi dengan gaya visual saat ini. Jika tidak, metode ini akan menggambar tombol opsi dengan gaya Windows klasik.

Berlaku untuk

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

Menggambar kontrol tombol opsi (juga dikenal sebagai tombol radio) dalam status dan lokasi yang ditentukan; dengan teks, pemformatan teks, dan gambar yang ditentukan; dan dengan persegi panjang fokus opsional.

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)

Parameter

g
Graphics

yang Graphics digunakan untuk menggambar tombol opsi.

glyphLocation
Point

tombol Point untuk menggambar opsi glyph at.

textBounds
Rectangle

Yang Rectangle akan ditarik radioButtonText .

radioButtonText
String

untuk String menggambar dengan tombol opsi.

font
Font

Font untuk diterapkan ke radioButtonText.

flags
TextFormatFlags

Kombinasi bitwise dari TextFormatFlags nilai.

image
Image

untuk Image menggambar dengan tombol opsi.

imageBounds
Rectangle

Yang Rectangle akan ditarik image .

focused
Boolean

true untuk menggambar persegi panjang fokus; jika tidak, false.

state
RadioButtonState

Salah RadioButtonState satu nilai yang menentukan status visual tombol opsi.

Keterangan

Jika gaya visual diaktifkan dalam sistem operasi dan gaya visual diterapkan ke aplikasi saat ini, metode ini akan menggambar tombol opsi dengan gaya visual saat ini. Jika tidak, metode ini akan menggambar tombol opsi dengan gaya Windows klasik.

Berlaku untuk