Can I evaluate two groups of items with a foreach loop in C# winforms?
c#, foreach, winforms
Solution
foreach(TabPage page in yourTabControl.TabPages){
foreach(Control c in page.Controls){
LoopThroughControls(c);
}
}
private void LoopThroughControls(Control parent){
foreach(Control c in parent.Controls)
LoopThroughControls(c);
}
Problem
I have a winforms TabControl and I am trying to cycle through all the controls contained in each tab. Is there a way to add `and` in a `foreach` loop or isn't it possible to evaluate more than one group of items? For example this is what I'd like to do: ``` foreach (Control c in tb_Invoices.Controls and tb_Statements.Controls) { //do something } ``` OR ``` foreach (Control c in tb_Invoices.Controls, tb_Statements.Controls) { //do something } ``` Is this possible, and if not, what is the next best thing? Do I need to use a `for` loop?