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

  • 相关阅读:
    wpf 用c#代码给img指定uri
    c 指针作为出参
    wpf获得系统毫秒数
    绑定元素的长宽(Canvas的子类自动伸展)
    PB与COM之关于创建COM,MTS, and COM+组件(1)
    ASA破解密码
    遭遇奸商(显卡篇)
    “启动Word时提示出错,只能用安全模式才能打开”的解决方法
    PowerSocket对象与HostName
    制做集成SATA驱动的XP安装盘
  • 原文地址:https://www.cnblogs.com/xiaotuni/p/2365725.html
Copyright © 2011-2022 走看看