ITPub博客

首页 > IT职业 > IT图书 > C#里面的单选框RadioButton的属性和事件

C#里面的单选框RadioButton的属性和事件

IT图书 作者:jockeyw 时间:2021-09-09 09:51:30 0 删除 编辑

在C#语言里面,单选框的属性和其它编程语言确实非常的相似。

主要的属性就是:Name、Text。事件主要的就是:CheckedChanged。

比如:创建一个简单的实例,选择春夏秋冬。就可以直接选中RadioButton组件,在窗口上面拉出4个单选框来。然后,分别修改Text属性为:春、夏、秋、冬。界面如下图:

图片描述


接下来可以分别设置每个单选框组件的CheckedChanged事件。

代码如下:

        void RadioButton1CheckedChanged(object sender, EventArgs e)
        {
            MessageBox.Show(radioButton1.Text);
        }
        void RadioButton2CheckedChanged(object sender, EventArgs e)
        {
            MessageBox.Show(radioButton2.Text);
        }
        void RadioButton3CheckedChanged(object sender, EventArgs e)
        {
            MessageBox.Show(radioButton3.Text);
        }
        void RadioButton4CheckedChanged(object sender, EventArgs e)
        {
            MessageBox.Show(radioButton4.Text);
        }

原文链接:http://www.apkbus.com/blog-56257-75887.html

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2063/viewspace-2813515/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-16

  • 博文量
    73
  • 访问量
    554