RadioButtonRenderer.DrawRadioButton 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
绘制选项按钮控件(也称为单选按钮)。
重载
| 名称 | 说明 |
|---|---|
| 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)
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
在指定状态和位置绘制选项按钮控件(也称为单选按钮)。
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)
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
使用指定的文本和可选焦点矩形绘制指定状态和位置中的选项按钮控件(也称为单选按钮)。
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)
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
使用指定的文本和文本格式以及可选的焦点矩形绘制指定状态和位置的选项按钮控件(也称为单选按钮)。
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)
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
使用指定的文本和图像以及可选的焦点矩形绘制指定状态和位置中的选项按钮控件(也称为单选按钮)。
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)
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
- Source:
- RadioButtonRenderer.cs
在指定状态和位置绘制选项按钮控件(也称为单选按钮);具有指定文本、文本格式和图像;以及具有可选焦点矩形。
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样式绘制选项按钮。