zoukankan      html  css  js  c++  java
  • 获取和赋值checkbox,radiobutton,页面所有控件只读

    赋值:

     foreach (Control tb in form1.Controls)
                    {
                        if (tb is TextBox)
                        {
                            TextBox t = tb as TextBox;
                            t.ReadOnly = true;
                        }
                    }
                    foreach (Control ctl in chk_offer.Controls)
                    {
                        if (ctl is CheckBox)
                        {
                            CheckBox ck = ctl as CheckBox;
                            if (str.IndexOf(ck.Text) > -1)
                            {
                                ck.Checked = true;
                            }
                        }
                    }

    if (st == "Public")
                    {
                        RadioButton5.Checked = true;
                    }
                    if (st == "Private")
                    {
                        RadioButton6.Checked = true;
                    }
                    if (st == "Others")
                    {
                        RadioButton7.Checked = true;
                    }

    取值:

     foreach (Control tb in form1.Controls)
                {
                    if (tb is TextBox)
                    {
                        TextBox t = tb as TextBox;
                        t.ReadOnly = false;
                    }
                }

    foreach (Control ctl in chk_offer.Controls)
                {
                    if (ctl is CheckBox)
                    {
                        CheckBox ck = ctl as CheckBox;
                        if (ck.Checked == true)
                        {
                            mp.Product += ck.Text + ",";

                        }
                    }
                }

     mp.Product = mp.Product.Substring(0, mp.Product.Length - 1);

       foreach (Control ctl in rad_type.Controls)
                {
                    if (ctl is RadioButton)
                    {
                        RadioButton rd = ctl as RadioButton;
                        if (rd.Checked == true)
                        {
                            mp.Ownership = rd.Text;
                        }
                    }
                }

  • 相关阅读:
    leetcode 78 子集
    leetcode 404 左叶子之和
    《数学有意思》28杠杆原理 29信息革命 30可信的数学
    《数学有意思》25中心极限定理 26混沌现象 27焦虑
    《数学有意思》22算术和几何 23统计学 24概率
    《数学有意思》19数学语言 20函数 21无理数
    《数学有意思》16归纳法 17因果关系 18物理学
    《数学有意思》13度量的本质 14度量单位 15科学也是一种模型
    《数学有意思》10思维工具 11选择合适的数学模型 12几何学
    《数学有意思》07公理是“公认的道理”吗 08什么是好的公里系统 09数学模型
  • 原文地址:https://www.cnblogs.com/suan1717/p/6232761.html
Copyright © 2011-2022 走看看