The example usage of RadioButton in C #
This article introduces the knowledge of "example usage of RadioButton in C#". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
C # RadioButton is a control that we often use, with so many properties, but we only need to master a few of them. Here is a brief introduction.
The C # RadioButton radio button is typically used as a group.
1.C# RadioButton allows users to select only one of several options, and can only select one button at a time in the same container.
The Appearance property of 2.C# RadioButton: controls the appearance based on the following two values:
Normal: circle + label, which will fill the circle when selected
Button: button, similar to a switch, pressed when selected and raised when unchecked
Checked attribute of 3.C# RadioButton:
True: selected
False: not selected
The CheckedAlign property of 4.C# RadioButton: determines the relative position of the circle to the label text.
Using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace TestRadioButton {public partial class Form1: Form {public Form1 () {InitializeComponent ();} private void button1_Click (object sender, EventArgs e) {string checkedRBName = "" / / get the name of the selected radio button if (radioButton1.Checked) {checkedRBName = radioButton1.Name;} else if (radioButton2.Checked) {checkedRBName = radioButton2.Name } else {checkedRBName = radioButton3.Name;} MessageBox.Show (checkedRBName + "was checked.");}} "instance usage of RadioButton in C#" ends here. Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!