I have multiple groups of controls on my form that changes together on a specific event … but the changes are everytime the same and only the names of the controls are different.
So I have to do:
label1.Text = "ready";
label2.Text = "let's go";
label1.ForeColor = System.Drawing.Color.Green;
label2.ForeColor = System.Drawing.Color.LightGreen
textbox1.Enabled = true;
textbox2.Enabled = true;
button1.Enabled = true;
button2.Enabled = true;
or
label1.Text = "not ready";
label2.Text = "just waiting to get ready";
label1.ForeColor = System.Drawing.Color.Red;
label2.ForeColor = System.Drawing.Color.Orange;
textbox1.Enabled = false;
textbox2.Enabled = false;
button1.Enabled = false;
button2.Enabled = false;
in each of the events, but for label3+label4 or label5+label6 etc. instead.
So my thought was, if it’s possible to put the groups of controls in something like a container and then call a method with the container as parameter.
like:
setReady(container);
setNotReady(container);
and this method would then do all the stuff I want.
So my question is, how would such a method look like resp. how can I access controls inside a container in this way? Or is there maybe a better way to handle something like this?
Group them in a
List< Control >