Hi, I am having problem with a particular process of commands. My program begins with detecting whether a textbox is empty at the press of a button and if it is it will display an error code which i scripted to do, you can create up to 10 textboxes which is where i have the problem because i need to check each runtime created textbox to see if it is empty, the first problem i have is that i get one message box displayed per empty textbox, this is the code i am using.
foreach (Control ctrl in panel1.Controls)
{
TextBox tb = ctrl as TextBox;
{
if (tb != null)
{
if (!string.IsNullOrEmpty(tb.Text))
{
Form2 form2 = new Form2();
form2.Show();
}
else
{
MessageBox.Show("Error1, Please Enter Areas In Numeric Area And Fill In All Text Boxes");
}
}
As you can see if the textbox has something in it form2 will open which is the problem because if up to 10 textboxes have writing in it which is my goal then 10 form2's will open. Can anyone help me with this problem please?