zoukankan      html  css  js  c++  java
  • 批处理按钮

       题目:根据数组S_Roles中的值,来批量设置Button的Enabled属性

      方法一:

          foreach (string s in S_Roles)
                {
                    switch (s)
                    {
                        case "1":
                            btn_1.Enabled = true;
                            break;
                        case "2":
                            btn_2.Enabled = true;
                            break;
                        case "3":
                            btn_3.Enabled = true;
                            break;
                        case "4":
                            btn_4.Enabled = true;
                            break;
                        case "5":
                            btn_5.Enabled = true;
                            break;
                        case "6":
                            btn_6.Enabled = true;
                            break;
                        case "7":
                            btn_7.Enabled = true;
                            break;
                        default:
                            break;

                    }
                }

    方法二:string b = string.Empty;   //构建字符串
                foreach (string s in S_Roles)
                {
                    b = "btn_" + s.ToString();
                    Button buttons = (Button)this.FindControl(b);
                    buttons.Enabled = true;
                }

    个人比较喜欢第二中方法。

  • 相关阅读:
    Playwright安装及基本用法
    生成随机数、随机字符串
    xmind2testcase使用
    jmeter5.0二次开发环境搭建(IDEA)
    pytest配置文件pytest.ini
    pytest+allure2生成测试报告
    pytest生成html报告-使用pytest-html插件方式
    pytest一些简单参数
    pytest简单搭建和入门
    python3学习-元组
  • 原文地址:https://www.cnblogs.com/jsping/p/2546595.html
Copyright © 2011-2022 走看看