I am trying to focus on the first empty TextBox
item.
How can I focus on the first empty TextBox
?
Do a foreach
loop to iterate through all TextBox
es in your Form.
Example:
foreach (TextBox tb in Controls.OfType<TextBox>()) {
if (string.IsNullOrWhiteSpace(tb.Text)) {
tb.Focus();
break;
}
}