【实例】
完成选择用户权限的操作,并在消息框中显示所选的权限名
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RadioButton
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//单击“确定”按钮的事件
private void button1_Click(object sender, EventArgs e)
{
/*
*Checked 属性可用于判断单选按钮是否被选中。
*如果该属性的返回值为 True,则代表选中;如果返回值为 False,则表示未选中。
*/
string msg = "";
if (radioButton1.Checked)
{
msg = radioButton1.Text;
}
else if (radioButton2.Checked)
{
msg = radioButton2.Text;
}
else if (radi