C# .NET中如何判断所有的文本框都输入

来源:百度知道 编辑:UC知道 时间:2024/05/16 14:21:37
C# .NET中如何判断所有的文本框都输入
并且把获得的信息都输出来

private string GetAllText()
{
string text = string.Empty;
foreach (Control control in this.Controls)
{
if (control is System.Windows.Forms.TextBox)
{
// control object 转成 textbox
TextBox controltxt = (TextBox)control;
//
if (controltxt.Text.Length == 0)
MessageBox.Show("存在空值Text");
else
text += controltxt.Text + ",";
}
}
return text.Length!=0?text.Remove(text.Length - 1):string.Empty;
}

总是抢先,总是抢先总是抢先总是抢先...