共用方式為


RadioButtonRenderer.DrawRadioButton 方法

定義

繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

多載

DrawRadioButton(Graphics, Point, RadioButtonState)

在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

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

使用指定的文字以及選擇性的焦點矩形,在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

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

使用指定的文字和文字格式,以及選擇性的焦點矩形,在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

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

使用指定的文字和影像,以及選擇性的焦點矩形,在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

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

使用指定的文字、文字格式和影像,以及選擇性的焦點矩形,在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

DrawRadioButton(Graphics, Point, RadioButtonState)

來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs

在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

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)

參數

g
Graphics

繪製選項按鈕所用的 Graphics

glyphLocation
Point

要在上面繪製選項按鈕圖像的 Point

state
RadioButtonState

其中一個 RadioButtonState 值,指定選項按鈕的可見狀態。

備註

如果在作業系統中啟用視覺化樣式,並將視覺化樣式套用至目前的應用程式,這個方法將會使用目前的視覺化樣式繪製選項按鈕。 否則,此方法會使用傳統 Windows 樣式繪製選項按鈕。

適用於

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

來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs

使用指定的文字以及選擇性的焦點矩形,在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

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)

參數

g
Graphics

繪製選項按鈕所用的 Graphics

glyphLocation
Point

要在上面繪製選項按鈕圖像的 Point

textBounds
Rectangle

要繪入 radioButtonTextRectangle

radioButtonText
String

隨選項按鈕一起繪製的 String

font
Font

要套用至 radioButtonTextFont

focused
Boolean

true 表示繪製焦點矩形,否則為 false

state
RadioButtonState

其中一個 RadioButtonState 值,指定選項按鈕的可見狀態。

範例

下列程式碼範例會在 DrawRadioButton(Graphics, Point, Rectangle, String, Font, Boolean, RadioButtonState) 自訂控制項的 OnPaint 方法中使用 方法,在滑鼠指標的位置所決定的狀態中繪製選項按鈕。 此程式碼範例是提供給 類別之較大範例的 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

備註

如果在作業系統中啟用視覺化樣式,並將視覺化樣式套用至目前的應用程式,這個方法將會使用目前的視覺化樣式繪製選項按鈕。 否則,此方法會使用傳統 Windows 樣式繪製選項按鈕。

適用於

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

來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs

使用指定的文字和文字格式,以及選擇性的焦點矩形,在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

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)

參數

g
Graphics

繪製選項按鈕所用的 Graphics

glyphLocation
Point

要在上面繪製選項按鈕圖像的 Point

textBounds
Rectangle

要繪入 radioButtonTextRectangle

radioButtonText
String

隨選項按鈕一起繪製的 String

font
Font

要套用至 radioButtonTextFont

flags
TextFormatFlags

TextFormatFlags 值的位元組合。

focused
Boolean

true 表示繪製焦點矩形,否則為 false

state
RadioButtonState

其中一個 RadioButtonState 值,指定選項按鈕的可見狀態。

備註

如果在作業系統中啟用視覺化樣式,並將視覺化樣式套用至目前的應用程式,這個方法將會使用目前的視覺化樣式繪製選項按鈕。 否則,此方法會使用傳統 Windows 樣式繪製選項按鈕。

適用於

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

來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs

使用指定的文字和影像,以及選擇性的焦點矩形,在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

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)

參數

g
Graphics

繪製選項按鈕所用的 Graphics

glyphLocation
Point

要在上面繪製選項按鈕圖像的 Point

textBounds
Rectangle

要繪入 radioButtonTextRectangle

radioButtonText
String

隨選項按鈕一起繪製的 String

font
Font

要套用至 radioButtonTextFont

image
Image

隨選項按鈕一起繪製的 Image

imageBounds
Rectangle

要繪入 imageRectangle

focused
Boolean

true 表示繪製焦點矩形,否則為 false

state
RadioButtonState

其中一個 RadioButtonState 值,指定選項按鈕的可見狀態。

備註

如果在作業系統中啟用視覺化樣式,並將視覺化樣式套用至目前的應用程式,這個方法將會使用目前的視覺化樣式繪製選項按鈕。 否則,此方法會使用傳統 Windows 樣式繪製選項按鈕。

適用於

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

來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs
來源:
RadioButtonRenderer.cs

使用指定的文字、文字格式和影像,以及選擇性的焦點矩形,在指定的狀態下和位置中繪製選項按鈕 (Option button) 控制項 (也稱為選項按鈕 (Radio button))。

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)

參數

g
Graphics

繪製選項按鈕所用的 Graphics

glyphLocation
Point

要在上面繪製選項按鈕圖像的 Point

textBounds
Rectangle

要繪入 radioButtonTextRectangle

radioButtonText
String

隨選項按鈕一起繪製的 String

font
Font

要套用至 radioButtonTextFont

flags
TextFormatFlags

TextFormatFlags 值的位元組合。

image
Image

隨選項按鈕一起繪製的 Image

imageBounds
Rectangle

要繪入 imageRectangle

focused
Boolean

true 表示繪製焦點矩形,否則為 false

state
RadioButtonState

其中一個 RadioButtonState 值,指定選項按鈕的可見狀態。

備註

如果在作業系統中啟用視覺化樣式,並將視覺化樣式套用至目前的應用程式,這個方法將會使用目前的視覺化樣式繪製選項按鈕。 否則,此方法會使用傳統 Windows 樣式繪製選項按鈕。

適用於