I have set all my TextBoxs.readOnly = true;
in the form by default.
But when an Edit Button
is clicked.
I want it to make all the TextBoxs.readOnly = false;
I have tried;
private void btnEdit_Click(object sender, EventArgs e)
{
foreach (var textBox in this.Controls.OfType<TextBox>())
textBox.ReadOnly = false;
}
Each TextBox
has a unique name.
The easiest way to do it would be this, below. But I don't want to do it that way.
txtName.ReadOnly = false;
txtAddress.ReadOnly = false;
...