Skip to content

Instantly share code, notes, and snippets.

@viko16
Created August 11, 2013 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viko16/6203662 to your computer and use it in GitHub Desktop.
Save viko16/6203662 to your computer and use it in GitHub Desktop.
检查各个控件是否有空值 #winform
/// <summary>
/// 检查各个控件是否有空值
/// </summary>
/// <returns>无空值返回true</returns>
private Boolean CheckEmpty()
{
foreach (Control cur in this.Controls)
{
//if (cur is TextBox && cur.Text == "") /*两种方式皆可,下面的更好*/
if(cur is TextBox && string.IsNullOrEmpty(cur))
{
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment