`
wsql
  • 浏览: 11805656 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

批量清楚控件的数据

 
阅读更多

///<summary>

///清空所有的文本框

///</summary>

privatevoidClearAllTextBox()

{

foreach(Controlcontrolinthis.groupBox1.Controls)

{

if(controlisTextBox)

{

((TextBox)control).Text="";

}

}

}

if(control.GetType().ToString()=="System.Windows.Forms.TextBox")

privatevoidClearTextBoxAndComboBoxAndCheckBox()

{

foreach(Controlcinthis.Controls)

{

if(c.GetType().ToString().Contains("TextBox"))

{

((TextBox)c).Text="";

}

if(c.GetType().ToString().Contains("ComboBox"))

{

((ComboBox)c).Text="";

}

if(c.GetType().ToString().Contains("CheckBox"))

{

((CheckBox)c).Checked=false;

}

}

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics