RadioButton Class
Assembly: System.Windows.Forms (in system.windows.forms.dll)
'Declaration <ComVisibleAttribute(True)> _ <ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _ Public Class RadioButton Inherits ButtonBase 'Usage Dim instance As RadioButton
/** @attribute ComVisibleAttribute(true) */ /** @attribute ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) */ public class RadioButton extends ButtonBase
ComVisibleAttribute(true) ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch) public class RadioButton extends ButtonBase
The RadioButton control can display text, an Image, or both.
When the user selects one option button (also known as a radio button) within a group, the others clear automatically. All RadioButton controls in a given container, such as a Form, constitute a group. To create multiple groups on one form, place each group in its own container, such as a GroupBox or Panel control.
RadioButton and CheckBox controls have a similar function: they offer choices a user can select or clear. The difference is that multiple CheckBox controls can be selected at the same time, but option buttons are mutually exclusive.
Use the Checked property to get or set the state of a RadioButton. The option button's appearance can be altered to appear as a toggle-style button or as a standard option button by setting the Appearance property.
The following code example creates and initializes a RadioButton, gives it the appearance of a toggle button, sets its AutoCheck property to false, and adds it to a Form.
Private Sub InitializeMyRadioButton() ' Create and initialize a new RadioButton. Dim radioButton1 As New RadioButton() ' Make the radio button control appear as a toggle button. radioButton1.Appearance = Appearance.Button ' Turn off the update of the display on the click of the control. radioButton1.AutoCheck = False ' Add the radio button to the form. Controls.Add(radioButton1) End Sub
private void InitializeMyRadioButton()
{
// Create and initialize a new RadioButton.
RadioButton radioButton1 = new RadioButton();
// Make the radio button control appear as a toggle button.
radioButton1.set_Appearance(Appearance.Button);
// Turn off the update of the display on the click of the control.
radioButton1.set_AutoCheck(false);
// Add the radio button to the form.
get_Controls().Add(radioButton1);
} //InitializeMyRadioButton
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.ButtonBase
System.Windows.Forms.RadioButton
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.