Accessing child controls in C# with foreach

Simplest way to clear all combo Box/TextBox in Visual Studio C#  2015 is using foreach loop and moving through the control collection.

What about controls grouped within  a group box, things getting complicated,isn’t it? Let me explain how can it get done.

  • First we going through the Base control collection and get each and every control.
  • Secondly we are looking inside each controls if they have child.
  • We further search for the TextBox and ComboBox and do some formatting, or any usual activities you want.

Visual Studio 2015 Tips: Double press Tab after you type foreach for snippet to be inserted, so that you can do more with less time.      

Published by


A developer,teacher and a blogger obsessed with Python,Dart and open source world from India

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.