1. common attributes:
(1) Checked attribute: Used to set or return whether the single-choice button is selected. The selected value is true, and the unselected value is false.
(2) AutoCheck attribute: If the AutoCheck attribute is set to true (default), all other single-choice buttons in the group are automatically cleared when this single-choice button is selected. For general users, you do not need to change this attribute. Use the default value (true.
(3) Appearance attribute: used to obtain or set the Appearance of a Single-choice button control. When the value is Appearance. Button, the Appearance of the single-choice Button is the same as that of the command Button: when it is selected, it appears to have been pressed. When the value is Appearance. Normal, It is the Appearance of the default single-choice button.
(4) Text attribute: Used to set or return the Text displayed in the control of the single-choice button. This attribute can also contain an access key, that is, the Text with "&"
In this way, you can select the control by pressing both the Alt key and the access key.
2. Common events:
(1) Click Event: When you Click the single-choice button, the Checked attribute value of the single-choice button is set to true, and the Click event occurs simultaneously.
(2) CheckedChanged event: When the Checked attribute value is changed, the CheckedChanged event is triggered.
Radiobutton in WPF may be different from that in Web, and it does not have attributes such as group. When using a group of radiobutton directly into a groupBox or panel, they are automatically in A group. There are two methods to use (determine which one is selected:
Method 1:
Copy codeThe Code is as follows:
Foreach (Control ctrl in groupBox1.Controls)
{
If (ctrl is RadioButton)
{
If (RadioButton) ctrl). Checked)
{
// Add the operation you need
}
}
}
Method 2: add events in each radiobutton
Copy codeThe Code is as follows:
Private void radioButton_CheckedChanged (object sender, EventArgs e)
{
RadioButton rb = (RadioButton) sender;
If (rb. Checked)
{
// Add the operation you need
}
}