zoukankan      html  css  js  c++  java
  • 批量设置窗体控件上的属性

           /// <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;判断设备的电源、网络、整机、故障状态。
            }
     

  • 相关阅读:
    Python中获取异常(Exception)信息
    Python 3.5 连接Mysql数据库(pymysql 方式)
    用命令查看Mysql中数据库、表的空间大小
    MySQLdb操作mysql的blob值
    mysql.connector操作mysql的blob值
    windows获取硬盘使用率等信息
    python操作系统环境变量
    git clone
    在Spring项目中使用Log4j记录日志
    org.apache.log4j.Logger详解
  • 原文地址:https://www.cnblogs.com/xiaotuni/p/2365725.html
Copyright © 2011-2022 走看看