-2

enter image description here My form

So, i have this Form with a TableLayoutPanel witch contains text boxes. I need the code to check if there is a textbox on my form and it is empty - then write text in it else {keep looking for an existing, empty text box} The order doesn't matter

  • Did you try to write a loop over the Controls collection of your TableLayoutPanel? – Steve Feb 02 '20 at 17:27
  • `tableLayoutPanel1.Controls.OfType() .Where(x=>string.IsNullOrEmpty(x.Text)).ToList().ForEach(x=>x.Text = "something");` – Reza Aghaei Feb 02 '20 at 17:48

1 Answers1

0
foreach (Control contr in tableLayoutPanel1.Controls)
        {
            if (contr is RichTextBox)
            {
                if ((contr as RichTextBox).Text == string.Empty)
                {
                    contr.Text = str_product;
                }
            }

        }