I have a tab control in my Windows Form, and I want to iterate over each element in two different tabs. When the file opens, I want all the elements of both to be included, and when the file is closed, all should be disabled.
I do not know how to do this, however, since the controls are not in the array or list, but in the ControlsCollection. I asked about foreach statements a second time and found out a little about lambda, but I don't know how I can apply it here.
Here is what I have:
List<Control.ControlCollection> panels = new List<Control.ControlCollection>(); panels.Add(superTabControlPanel1.Controls); panels.Add(superTabControlPanel2.Controls); foreach(Control.ControlCollection ctrlc in panels){ foreach (Control ctrl in ctrlc) { } }
Is this possible with a single foreach clause, or is it somehow simpler?
source share