• 获取和赋值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;
                        }
                    }
                }

  • 相关阅读:
    为什么我的Android SDK Manager中只显示已安装的package?
    解决Android Studio Gradle Build特别慢的问题
    一款不错的取色器
    Android Studio没有导包快捷键怎么办
    Android Studio中有没有类似于Eclipse中的ctrl+2+L的快捷键? Android Studio快捷键之代码提示
    安卓动画总结【非原创】
    ButterKnife-5.1.2.jar(较低版本的ButterKnife)使用方法
    【转】调用getActionBar()报Call requires API level 11 (current min is 8): android.app.Activity#getActionBar
    spring容器加载完毕做一件事情(利用ContextRefreshedEvent事件)转
    详解 Spring 3.0 基于 Annotation 的依赖注入实现(转)
  • 原文地址:https://www.cnblogs.com/suan1717/p/6232761.html
Copyright © 2020-2023  润新知