zoukankan      html  css  js  c++  java
  • C#递归操作设置某类控件

    我们经常会遇到将某类所有控件,进行设置执行某种操作。一般有如下几种:

    1.判断输入控件是否为空?

    2.将所有输入控件清空。

    3.设置所有控件的某类属性,比如颜色、是否可用等等。

     

    清空所有输入控件,代码如下:

    代码
            /// <summary>
            
    /// 递归方法清空控件
            
    /// </summary>
            
    /// <param name="ctrl"></param>
            private void SetControlEmpty(Control ctrl)
            {
               
                
    foreach (Control ctl in ctrl.Controls)
                {

                    
    if (ctl is TextBox)
                    {
                        ctl.Text 
    = "";
                    }
                    
    else
                    {
                        
    if (ctl.Controls.Count > 0)
                        {
                            SetControlEmpty(ctl);
                        }
                    }
                }
               
            } 
  • 相关阅读:
    this.$router.push({})实现路由跳转
    JavaScript 实用小技巧
    js中如何实现数组去重--面试题
    面试中知识点积累
    从输入url到网页呈现的过程
    ptyhon学习---作业day1
    python学习---for循环
    python学习---while循环
    python学习---if else流程判断
    ajax最基础入门
  • 原文地址:https://www.cnblogs.com/lumnm/p/1670210.html
Copyright © 2011-2022 走看看