Introduction to common properties and methods of ASP. NET radio button control RadioButton

Source: Internet
Author: User

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
}
}


 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.