本文介绍了C#忽略空文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我一直在寻找一种方法来检查表单中的所有文本框是否为空,如果没有显示消息。其中一些是不可见的。 我有下面的代码,但它不能以某种方式工作,当我点击确定我得到一个错误,因为文本框是空的。 有人可以帮忙吗? 提前付款 我尝试过:Hi,i´ve been searching for a way to check if all textboxes from a form a empty and if not show a message. Some of them are not visible.I have the code below but it´s not working somehow, when i click ok i get an error because a textbox is empty.Can anyone help please ?Thanks in advanceWhat I have tried:foreach (Control c in Controls){ if (c is TextBox && c.Visible && string.IsNullOrEmpty(c.Text)) { MessageBox.Show($"TextBox {c.Name} is empty"); }}推荐答案if (larg.Text == string.Empty){ if (larg.Visible == False) { MessageBox.Show("info missing", "Warning"); return; }} Etcetera。Etcetera. 这篇关于C#忽略空文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!