1. Common attributes:
(1) Checked attribute: used to set or return whether the radio button is selected. The value is true when selected, and false when not selected.
(2) AutoCheck property: If the AutoCheck property is set to true (default), then when this radio button is selected, all other radio buttons in the group will be automatically cleared. For ordinary users, there is no need to change this attribute and just use the default value (true).
(3) Appearance property: used to get or set the appearance of the radio button control. Appearance.Button makes the radio button look like a command button: when it is selected, it appears to be pressed. When the value is Appearance.Normal, it is the default radio button appearance.
(4) Text property: used to set or return the text displayed in the radio button control. This property can also contain access keys, that is, letters preceded by the "&"
symbol , so the user can select the control by pressing the Alt key and the access key simultaneously.
2. Commonly used events:
(1) Click event: When a radio button is clicked, the Checked attribute value of the radio button will be set to true, and a Click event will occur at the same time event.
(2) CheckedChanged event: When the value of the Checked attribute changes, the CheckedChanged event will be triggered.
The radiobutton in WPF may be different from that in the Web. It does not have attributes such as group. When using, directly put the radiobuttons of the same group into a groupBox or panel, and they will automatically be a group. There are two ways to use it (to determine which one is selected):
First First method:
foreach (Control ctrl in groupBox1.Controls) { if (ctrl is RadioButton) { if (((RadioButton)ctrl).Checked ) { //添加你需要的操作 } } }
Second method: Add events in each radiobutton
private void radioButton_CheckedChanged(object sender, EventArgs e) { RadioButton rb=(RadioButton) sender; if (rb.Checked) { //添加你需要的操作 } }
For more introduction to the common properties and methods of the ASP.NET radio button control RadioButton, please pay attention to PHP Chinese for related articles net!