473,491 Members | 3,350 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

for each on multiple collections

KR
I finally got back to this. The syntax that worked for me was:

For Each ctlarray As Control.ControlCollection _
In New Control.ControlCollection() _
{ Form1.Controls _
, Form1.tabPage1.Controls _
, Form2.TabPage2.Controls _
}
For Each ctl As Control _
In ctlarray
' Do stuff
Next
Next

KW

---------- original post ----------
From: "Phill W." <p-.-a-.-w-a-...@o-p-e-n-.-a-c-.-u-k>
Date: Oct 4 2006, 10:36 am
Subject: for each on multiple collections
To: microsoft.public.dotnet.languages.vb
KW wrote:
Is there a way to do a "foreach" on multiple control collections?
Something like the following which obviously doesn't work:
foreachctl as control in form1.controls, form1.tabpage1.controls, form2.tabpage2.controls
next
Not directly, but you can loop through an /array/ of collections, then
through the Controls ineach, as in :

<AirCode()_
For Each e1 As ControlCollection _
In New ControlCollection() _
{ Form1.Controls _
, Form1.tabPage1.Controls _
, Form2.TabPage2.Controls _
}
For Each e2 As Control _
In e1.Controls
' Do stuff
Next
Next

HTH,
Phill W.

Mar 7 '07 #1
0 1170

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2029
by: njp | last post by:
BlankHi, How do I create a tightly coupled Object 1 such that when I update it in one collection, it is simultaneously and automatically updated in other collections? The collections are defined...
3
4709
by: BobforeApples | last post by:
Hi All, I was trying to apply databinding to a custom collection as in the MSDN Magazine article found in the August, 2005 issue. After converting the code in the article to C# and applying it to...
1
3318
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
7
2081
by: samoore33 | last post by:
I want to list all of the items in a dataset in a textbox. The dataset has multiple tables. When I try to use the code below, even though I dim myState as the DataTable("state"). It still looks for...
7
395
by: Kathy | last post by:
Is there a way to do a "for each" on multiple control collections? Something like the following which obviously doesn't work: for each ctl as control in form1.controls, form1.tabpage1.controls,...
1
4330
by: Dave A | last post by:
I have a problem that I have boiled down to a very simple example. I have a user control that displays a some data from a business object. On one screen I have a collection of these business...
6
6895
by: Bugs | last post by:
Does anyone have any recommendations on the best way to create multiple instances of the same class when the final number of instances is unknown? For example, I have a class and based on some...
37
19142
by: bahoo | last post by:
Hi, I have a list like and as output I want If I myList.remove('0024') then only the first instance of '0024' is removed.
3
10539
by: raylopez99 | last post by:
This is an example of using multiple comparison criteria for IComparer/ Compare/CompareTo for List<and Array. Adapted from David Hayden's tutorial found on the net, but he used ArrayList so the...
0
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6862
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5452
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.