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
Asked
Active
Viewed 128 times
-2
-
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 Answers
0
foreach (Control contr in tableLayoutPanel1.Controls)
{
if (contr is RichTextBox)
{
if ((contr as RichTextBox).Text == string.Empty)
{
contr.Text = str_product;
}
}
}

andrew jonson
- 7
- 2
- 4