On the form 10-15 TextBox 's, you need to consistently check them for emptiness, as it can be rationally implemented, so as not to write 15 times

 if(tb1.Text=="") { } 

2 answers 2

You can sort out something like that if everything is in the root:

 foreach(var pb in this.Controls.OfType<TextBox>()) { //do stuff } 

and inside already run the check.

If there are GroupBoxes on the form, then you need to connect a recursion or a stack.

  • one
    well this is if they all lie in the root, and if you really need to check everything - VladD
  • need to check only to the first empty, and then return its index - Clarence

Adequate option, I think, will throw all the TB objects in the collection and check in the loop.