I have a Form 1 that opens Form2. How I make all textBox readonly in Form2 opens?
Form 1:
Form2 f2 = new Form2();
f2.ReadOnly();
f2.ShowDialog();
Form 2:
public void ReadOnyTextBoxes(Control parent)
{
foreach (Control c in parent.Controls)
{
if (c.GetType() == typeof(TextBox))
{
((TextBox)(c)).ReadOnly = true;
}
}
}
public void ReadOnly()
{
ReadOnyTextBoxes(groupBox1);
}