CryoEnix Posted February 2, 2007 Posted February 2, 2007 Is it possible in VB.NET to loop through a specific object within a form? Below is the pseudocode to what I want to achieve: for con = each Label in formMain con.backcolor=rgb(252,252,254) next Is this possible, and if so does anybody know the correct syntax? Quote Chaos is merely logic beyond human comprehension
alreadyused Posted February 2, 2007 Posted February 2, 2007 to my knowledge you cannot specify at first that you want only labels, so you have to: dim ctl as control for each ctl in formMain.Controls if typeof control is label then 'do your magic here end if 'label next note you can also do this to just a panel or groupbox Quote
Leaders snarfblam Posted February 2, 2007 Leaders Posted February 2, 2007 Note that unless you do a recursive search for controls, you will only find controls placed directly on the form (in other words, controls placed in panels and group boxes won't be found). Quote [sIGPIC]e[/sIGPIC]
CryoEnix Posted February 3, 2007 Author Posted February 3, 2007 Thanks very much guys, that was exactly what I was after - gonna go run to my app now and finish it off. Thanks again! ^^ Quote Chaos is merely logic beyond human comprehension
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.