Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6953931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:32:28+00:00 2026-05-27T14:32:28+00:00

How do I go about looping through all the controls within a container, and

  • 0

How do I go about looping through all the controls within a container, and all the controls in the container of a containing control, and so on.

Form
-Panel
--Control
--Tab
----Control
----Control
--Tab
----Control

The following only retrieves -Panel and none of the other controls

For Each cntrl As Control In Me.Controls

Next

How can I retrieve them all in a For Each loop without an If/Then for every level in the stack?

EDIT:

Dim ctl As Control = Me
Do
    ctl = Me.GetNextControl(ctl, True)
    'Do whatever you have to ctl
Loop Until ctl Is Nothing

This is so far the best method I found of doing this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:32:29+00:00Added an answer on May 27, 2026 at 2:32 pm

    You have to define a method that recursively traverse containers inside the container. Something like this:

     Dim _list As New List(Of Control)
     Public Sub GetChilds(container As Control)
            For Each child As Control In container.Controls
                _list.Add(child)
                If (child.HasChildren) Then
                    GetChilds(child)
                End If
            Next
     End Sub
    

    To call this method:

     list=new List(Of Control)
      GetChilds(Me)
      For Each cntrl As Control In _list
        ....
      Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just looking through some information about Google's protocol buffers data interchange format.
Over the past couple of weeks I've read through the book Error Control Coding:
I am using Silverlight WebBrowser Control in one of my application, and all the
I am looking to implement and learn more about the ASP.NET GridView control. However,
Although there are some threads on here about .net charting controls, I'm starting new
In my program, I'm looping through a datatable to get data from each field.
I need help with the Pythonic looping overhead of the following problem: I'm writing
I've been programming c++ for about a year now and when i'm looking about
I have a Postgres instance building a GIN index. It's looking at about 200,000
im looking for any information about a builtin algorithm in opengl es to convert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.