الاثنين، 28 نوفمبر 2011

Clear all Controls inside Container using Recursive techniques

 
   private void btnClear_Click(object sender, EventArgs e)
        {
            ClearControls(this);
        }

        private void ClearControls(Control c)
        {
            foreach (Control ctrl in c.Controls)
            {
                if (ctrl is TextBox)
                {
                    ctrl.Text = "";
                }

                else
                {
                    if (ctrl.Controls.Count > 0)
                    {
                        ClearControls(ctrl);
                    }

                }

            }
        }

0 التعليقات: