SSISO Community

갤러리정

foreach문을 이용한 폼컨트롤 초기화방법 - CSharp

* 폼에 포함되어 있는 모든 텍스트박스 초기화

 

            foreach(Control ctl in this.Controls)
            {
                if(typeof(System.Windows.Forms.TextBox)==ctl.GetType())
                {
                    ctl.Text = null;
                }
            }

 

* TabControl의 TabPages의 초기화

  // tabStudent는 TabContrl의 TabPages중 하나 

  // tabStudent에 포함된 모든 텍스트박스를 초기화 한다.

 

            foreach(Control ctl in tabStudent.Controls)
            {
                if(typeof(TextBox) == ctl.GetType())
                {
                    ctl.Text = null;
                }
            }


5014 view

4.0 stars