Winform循环清空界面所有控件值

  foreach (Control control in pnlTop.Controls)
            {
    
    
                //清空所有文本框
                if (control is TextBox )
                {
    
    
                    control.Text = string.Empty;
                }
                //清空下拉框
                if (control is ComboBox)
                {
    
    
                    (control as ComboBox).Text = string.Empty;
                }
                //清空复选框
                if (control is CheckBox)
                {
    
    
                    (control as CheckBox).Checked = false;
                }
            }

猜你喜欢

转载自blog.csdn.net/China_Marcy/article/details/106216338
今日推荐