• winform中CheckBox遍历小例子



    代码:

     private void button1_Click(object sender, EventArgs e)
            {
                StringBuilder sb = new StringBuilder();
                //遍历窗体上所有控件
                foreach (Control ctr in this.Controls)
                {
                    //判断该控件是不是CheckBox
                    if (ctr is CheckBox)
                    {
                        //将ctr转换成CheckBox并赋值给ck
                        CheckBox ck = ctr as CheckBox;
                        if (ck.Checked)
                        {
                            sb.AppendLine(ck.Text);
                        }
                    }

                }
                this.label2.Text = sb.ToString();

            }

  • 相关阅读:
    常见面试题1
    勒索病毒防范方法
    VMware虚拟机打开后不兼容
    win10桌面显示我的电脑设置
    scala集合和Java集合对应转换操作
    scala中使用redis
    爬虫调研
    hadoop命令
    IDEA打jar包
    spark.mllib
  • 原文地址:https://www.cnblogs.com/ycxyyzw/p/1877657.html
Copyright © 2020-2023  润新知