RadioButtonRenderer.DrawRadioButton 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會顯示一個選項按鈕控制(也稱為單選鍵)。
多載
| 名稱 | Description |
|---|---|
| DrawRadioButton(Graphics, Point, RadioButtonState) |
在指定的狀態和位置繪製一個選項按鈕控制(也稱為單選按鈕)。 |
| DrawRadioButton(Graphics, Point, Rectangle, String, Font, Boolean, RadioButtonState) |
在指定狀態與位置繪製一個選項按鈕控制項(也稱為單選按鈕),並附上指定文字,並附有可選的焦點矩形。 |
| DrawRadioButton(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Boolean, RadioButtonState) |
在指定狀態與位置繪製一個選項按鈕控制項(也稱為單選按鈕),並附有指定的文字及文字格式,並附有可選的焦點矩形。 |
| DrawRadioButton(Graphics, Point, Rectangle, String, Font, Image, Rectangle, Boolean, RadioButtonState) |
在指定的狀態與位置繪製一個選項按鈕控制項(也稱為單選按鈕),並附上指定的文字與圖片,並可選地使用焦點矩形。 |
| DrawRadioButton(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, RadioButtonState) |
在指定狀態與位置繪製選項按鈕控制(也稱為單選按鈕);包含指定的文字、文字格式與圖片;並可選配對焦矩形。 |
DrawRadioButton(Graphics, Point, RadioButtonState)
在指定的狀態和位置繪製一個選項按鈕控制(也稱為單選按鈕)。
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)
參數
- state
- RadioButtonState
其中一個 RadioButtonState 值是指定選項按鈕視覺狀態的。
備註
如果作業系統啟用視覺樣式,且視覺風格套用到目前應用程式,此方法會繪製出顯示當前視覺樣式的選項按鈕。 否則,此方法會以經典 Windows 風格繪製選項按鈕。
適用於
DrawRadioButton(Graphics, Point, Rectangle, String, Font, Boolean, RadioButtonState)
在指定狀態與位置繪製一個選項按鈕控制項(也稱為單選按鈕),並附上指定文字,並附有可選的焦點矩形。
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)
參數
- 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)
在指定狀態與位置繪製一個選項按鈕控制項(也稱為單選按鈕),並附有指定的文字及文字格式,並附有可選的焦點矩形。
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)
參數
- flags
- TextFormatFlags
這是數值的位元組合 TextFormatFlags 。
- focused
- Boolean
true繪製焦點矩形;否則,。 false
- state
- RadioButtonState
其中一個 RadioButtonState 值是指定選項按鈕視覺狀態的。
備註
如果作業系統啟用視覺樣式,且視覺風格套用到目前應用程式,此方法會繪製出顯示當前視覺樣式的選項按鈕。 否則,此方法會以經典 Windows 風格繪製選項按鈕。
適用於
DrawRadioButton(Graphics, Point, Rectangle, String, Font, Image, Rectangle, Boolean, RadioButtonState)
在指定的狀態與位置繪製一個選項按鈕控制項(也稱為單選按鈕),並附上指定的文字與圖片,並可選地使用焦點矩形。
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)
參數
- focused
- Boolean
true繪製焦點矩形;否則,。 false
- state
- RadioButtonState
其中一個 RadioButtonState 值是指定選項按鈕視覺狀態的。
備註
如果作業系統啟用視覺樣式,且視覺風格套用到目前應用程式,此方法會繪製出顯示當前視覺樣式的選項按鈕。 否則,此方法會以經典 Windows 風格繪製選項按鈕。
適用於
DrawRadioButton(Graphics, Point, Rectangle, String, Font, TextFormatFlags, Image, Rectangle, Boolean, RadioButtonState)
在指定狀態與位置繪製選項按鈕控制(也稱為單選按鈕);包含指定的文字、文字格式與圖片;並可選配對焦矩形。
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)
參數
- flags
- TextFormatFlags
這是數值的位元組合 TextFormatFlags 。
- focused
- Boolean
true繪製焦點矩形;否則,。 false
- state
- RadioButtonState
其中一個 RadioButtonState 值是指定選項按鈕視覺狀態的。
備註
如果作業系統啟用視覺樣式,且視覺風格套用到目前應用程式,此方法會繪製出顯示當前視覺樣式的選項按鈕。 否則,此方法會以經典 Windows 風格繪製選項按鈕。