Asp. NET radio button control radiobutton Common Properties and methods _ Practical Tips

Source: Internet
Author: User

1. Common Properties:

(1) Checked property: used to set or return whether the radio button is selected, the check value is true, and no check value is false.

(2) AutoCheck property: If the AutoCheck property is set to True (the default), all other radio buttons in the group are automatically cleared when the radio button is selected. For the average user, you do not need to change this property to use the default value (TRUE).

(3) Appearance property: Used to get or set the appearance of a radio button control. When it takes a value of Appearance.Button, the radio button looks like a command button: It appears to have been pressed when it is selected. When the value is Appearance.normal, it is the appearance of the default radio button.

(4) Text property: Used to set or return the text displayed within a radio button control, which can also contain an access key, which is preceded with a "&"

The letter of the symbol so that the user can select the control by pressing the ALT key and the access key at the same time.


2. Common events:

(1) Click event: When the radio button is clicked, the Checked property value of the radio button is set to True, and the Click event occurs.

(2) CheckedChanged event: When the Checked property value changes, the CheckedChanged event is triggered.

The RadioButton in WPF may be different from the web, without attributes such as group. Put the same group of RadioButton into a GroupBox or panel when you use them, and they are automatically set, and there are two ways to use them (to determine which one is selected):

The first method:

Copy Code code as follows:

foreach (Control Ctrl-Groupbox1.controls)
{
If (Ctrl is RadioButton)
{
if ((RadioButton) ctrl). Checked)
{
Add the action you need
}
}
}

The second method: Add events to each RadioButton
Copy Code code as follows:

private void radioButton_CheckedChanged (object sender, EventArgs e)
{
RadioButton rb= (RadioButton) sender;
if (RB. Checked)
{
Add the action 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.