|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Question about Control Collection in VB.netHi.
I've got a form and I want to iterate through the controls on it. I've tried: For intCounter = 0 to Me.Controls.Count -1 ' do something next intCounter But the Me.Controls.Count only evaluates to 5, even though there are alot more controls on the form. Any Ideas? thanks, Matt Hi Matt,
Do the missing controls belong to the form or to other container control (GroupBox, TabControl)? In the latter case, you need to use recursion to get them. -- Show quoteHide quoteBest regards, Carlos J. Quintero MZ-Tools: Productivity add-ins for Visual Studio You can code, design and document much faster: http://www.mztools.com "matthew ware" <mattheww***@email.com> escribió en el mensaje news:%23pn8JKLKGHA.648@TK2MSFTNGP14.phx.gbl... > Hi. > > I've got a form and I want to iterate through the controls on it. I've > tried: > > For intCounter = 0 to Me.Controls.Count -1 > ' do something > next intCounter > > But the Me.Controls.Count only evaluates to 5, even though there are alot > more controls on the form. > > Any Ideas? > > thanks, > > Matt > Hi Carlos.
Brilliant! Yes, the missing controls were on a tab control - now fixed. thankyou, Matt. Show quoteHide quote "Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> wrote in message news:eHt4sMLKGHA.4068@TK2MSFTNGP10.phx.gbl... > Hi Matt, > > Do the missing controls belong to the form or to other container control > (GroupBox, TabControl)? In the latter case, you need to use recursion to > get them. > > -- > > Best regards, > > Carlos J. Quintero > > MZ-Tools: Productivity add-ins for Visual Studio > You can code, design and document much faster: > http://www.mztools.com > > > "matthew ware" <mattheww***@email.com> escribió en el mensaje > news:%23pn8JKLKGHA.648@TK2MSFTNGP14.phx.gbl... >> Hi. >> >> I've got a form and I want to iterate through the controls on it. I've >> tried: >> >> For intCounter = 0 to Me.Controls.Count -1 >> ' do something >> next intCounter >> >> But the Me.Controls.Count only evaluates to 5, even though there are alot >> more controls on the form. >> >> Any Ideas? >> >> thanks, >> >> Matt >> > > "matthew ware" <mattheww***@email.com> schrieb: \\\> I've got a form and I want to iterate through the controls on it. I've > tried: > > For intCounter = 0 to Me.Controls.Count -1 > ' do something > next intCounter > > But the Me.Controls.Count only evaluates to 5, even though there are alot > more controls on the form. Private Sub RecurseControls(ByVal ctr As Control) Debug.WriteLine(ctr.Name) If ctr.HasChildren Then For Each c As Control In ctr.Controls RecurseControls(c) Next c End If End Sub .. .. .. RecurseControls(Me) /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Search Arraylist in Arraylist.
Newbie Question: How To Open A File Non-Exclusively? PropertyBag in VB.NET? Saving a Database to Disk Windows Form Application Help Command line argument in NET Cast from string "" to type 'Date' is not valid Accessing controls from another thread unexpected split functionality - index out of bounds Using Named Pipes ? |
|||||||||||||||||||||||