C#中RadioButton的实例用法

发布时间:2021-09-09 10:04:35 作者:chen
来源:亿速云 阅读:252

本篇内容介绍了“ C#中RadioButton的实例用法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

C# RadioButton是大家经常用的一个控件,其属性之多,但是我们只需掌握其中几个就可以了,下面将做一下简单的介绍。

C# RadioButton单选按钮一般用作一个组。

1.C# RadioButton只允许用户从几个选项中选择一个,同一个容器中一次只能选择一个按钮;

2.C# RadioButton的Appearance属性:根据的以下两种取值控制外观:
Normal:圆圈+标签,选中后会填充圆圈;
Button:按钮,类似于开关,选中后按下,未选中时凸起;

3.C# RadioButton的Checked属性:
true:选中;
false: 未选中;
4.C# RadioButton的CheckedAlign属性:确定圆圈与标签文本的相对位置。

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 = "";                            //取得选中单选按钮的名称              if (radioButton1.Checked)              {                  checkedRBName = radioButton1.Name;              }              else if (radioButton2.Checked)              {                  checkedRBName = radioButton2.Name;              }              else             {                  checkedRBName = radioButton3.Name;              }              MessageBox.Show(checkedRBName + " was checked.");          }      }  }

“ C#中RadioButton的实例用法”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

推荐阅读:
  1. python中的with语句实例用法
  2. tkinter学习_radiobutton

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

上一篇:vue 2.5.1源码之Vue.extend和data合并策略的示例分析

下一篇:怎么通过重启路由的方法切换IP地址

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》