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

  • 相关阅读:
    字符串与模式匹配算法(一):BF算法
    Spring MVC:HandlerMapping
    Spring MVC:DispatchServlet类
    Spring:面向切面编程的AOP
    Java:检查异常与未检查异常
    AOP源码解析:AspectJExpressionPointcutAdvisor类
    Vue+Webpack打包之后超过url-loader大小限制的图片在css的background-image中使用路径问题
    less
    ES6模块的import和export用法总结
    bootstrap4网格
  • 原文地址:https://www.cnblogs.com/xiaotuni/p/2365725.html
Copyright © 2011-2022 走看看