|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
for each on multiple collectionsIs 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, form2.tabpage2.controls next Thanks, KW Kathy wrote:
> Is there a way to do a "for each" on multiple control collections? Not directly, but you can loop through an /array/ of collections, then > Something like the following which obviously doesn't work: > > for each ctl as control in form1.controls, form1.tabpage1.controls, > form2.tabpage2.controls > next through the Controls in each, 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. Yes! That's what I was looking for, thanks !!
KW Show quoteHide quote "Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-k> wrote in message news:eg0kel$st5$1@south.jnrs.ja.net... > Kathy wrote: >> 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, >> form2.tabpage2.controls >> next > > Not directly, but you can loop through an /array/ of collections, then > through the Controls in each, 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. Ooops, I spoke too soon. It sounded good, but I can't get it to work. To
start with, the ControlCollection in "For Each e1 As ControlCollection" is not recognized. I need a little more help please. Thanks. KW Show quoteHide quote "Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-k> wrote in message news:eg0kel$st5$1@south.jnrs.ja.net... > Kathy wrote: >> 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, >> form2.tabpage2.controls >> next > > Not directly, but you can loop through an /array/ of collections, then > through the Controls in each, 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. KW wrote:
> Ooops, I spoke too soon. It sounded good, but I can't get it to I believe this syntax was only added in VS2005. If you're using VS2003 or > work. To start with, the ControlCollection in "For Each e1 As > ControlCollection" is not recognized. I need a little more help > please. earlier, try replacing this with: \\\ Dim e1 As ControlCollection For Each e1 In New ControlCollection() { [etc] /// -- (O)enone I'm using VS2005. Intellisense says "type ControlCollection is not defined"
Show quoteHide quote "Oenone" <oen***@nowhere.com> wrote in message news:dLSUg.622$L.181@newsfe4-gui.ntli.net... > KW wrote: >> Ooops, I spoke too soon. It sounded good, but I can't get it to >> work. To start with, the ControlCollection in "For Each e1 As >> ControlCollection" is not recognized. I need a little more help >> please. > > I believe this syntax was only added in VS2005. If you're using VS2003 or > earlier, try replacing this with: > > \\\ > Dim e1 As ControlCollection > For Each e1 In New ControlCollection() { > [etc] > /// > > -- > > (O)enone > KW wrote:
> I'm using VS2005. Intellisense says "type ControlCollection is not In that case try putting the class hierarchy above ControlCollection, and > defined" use Windows.Forms.Control.ControlCollection instead. -- (O)enone To be sure you get all the child controls from other child controls, you will
need some type of recursion. Try the following (untested) 'Public Sub Get_Controls(ByVal parentCtr As Control) ' For Each ctr As Control In parentCtr.Controls ' Console.Write(ctr.Name) ' Get_Controls(ctr) ' Next 'End Sub -- Show quoteHide quoteDennis in Houston "Kathy" wrote: > 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, > form2.tabpage2.controls > next > > Thanks, > KW > > >
You're good if you can answer this one.....
Problem with access database, and VB .NET Office application object problem Microsoft Visual Studio 2005 Tools for Applications Extracting icon from file: most efficient method? Changing Printer's default paper How to convert code snipped from VB6 to Visual Studio 2005/VB (VB7?) Does a menu item lose dataset information? time constant test "file exists" on remote computer? |
|||||||||||||||||||||||