• 批量设置窗体控件上的属性


           /// <summary>
            /// 清空控件上的TextBox文本中的值,ComboBox、Button设置为灰色,
            /// </summary>
            /// <param name="IsEnabled">是否显示所有控件</param>
            /// <param name="status">状态信息</param>
            /// <param name="ctr">控件集合</param>
            public void ClearControlsTextValue(ref bool IsEnabled,DeviceStatusInfo status,Control.ControlCollection ctr)
            {
                if (status.PowerState == 1 || status.NetState == 1)// || status.ErrorState == "1")
                {
                    foreach (Control ctrl in ctr)
                    {
                        if (ctrl is TextBox)
                        {
                            ctrl.Text = "";
                        }//End if;判断是不是文本控件。

                        if (ctrl is ComboBox)
                        {
                            ComboBox comboBoxPower = ctrl as ComboBox;

                            if (comboBoxPower.Tag == null)
                            {
                                comboBoxPower.Enabled = false;
                            }//End if;判断是不是电源下拉框控件

                        }//End if;判断是不是下拉框控件。

                        if (ctrl is ProgressBar)
                        {
                            (ctr as ProgressBar).Enabled = false;
                        }//End if;判断是不是进度条控件。

                        if (ctrl.HasChildren)
                        {
                            ClearControlsTextValue(ref IsEnabled, status,ctrl.Controls);
                        }//End if; 递归子控件

                    }//End foreach;遍历所有控件。

                    IsEnabled = true;
                }//End if;判断设备的电源、网络、整机、故障状态。
            }
     

  • 相关阅读:
    测试方案
    如何编写一个好的测试计划
    一个好的测试过程
    java后台生成echarts图表并保存图片
    Javascript数组排序,并获取排序后位置对应的原索引(堆排序实现)
    修改tomcat编码方式
    json序列化反序列化后function丢失
    Mysql数据库存取性能优化
    java创建文件
    Java POI导出ppt简单实现
  • 原文地址:https://www.cnblogs.com/xiaotuni/p/2365725.html
Copyright © 2020-2023  润新知