Solved

Best way to loop thru controls on a form recursively?

Posted on 2014-04-10
2
418 Views
Last Modified: 2014-04-11
What is the most efficient way to loop thru all the controls on a form including controls within container controls?

Thanks!
0
Comment
Question by:BlakeMcKenna
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39993171
	Public Sub LoopThroughControls(container As Control)

		For Each ctl As Control In container.Controls
			'Do your stuff here...
			If ctl.Controls.Count > 0 Then
				LoopThroughControls(ctl)
			End If
			'... or here
		Next

	End Sub

Open in new window

A form is a Control, so you can send your form to that method, and it will recursively calls itself back when you encounter a Control that contains other Controls.
0
 

Author Closing Comment

by:BlakeMcKenna
ID: 39994075
Thanks James...exactly what I was looking for!
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question