[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Full list of controls in a form including those that are inside a container

Posted on 2011-02-17
5
Medium Priority
?
261 Views
Last Modified: 2012-05-11
I have a form with textboxes, labels, comboboxes and containers like tabpage or panels. If I use:
for each c in me.controls
....
I obtain each control in the form but not in the containers.
How can I obtain a list of controls in the form, its containers, containers inside containers, etc.?
0
Comment
Question by:BemboX
[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
  • 2
5 Comments
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 34919691
foreach (Control c in parent.Controls)
            {
                string foo = c.GetType().ToString();
                
                if (c.HasControls())
               {

               }
            }

Open in new window

0
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 34919695
Ooops remove the string foo line. I forgot to cut it out.
0
 

Author Comment

by:BemboX
ID: 34919812
Thanks for your answer, but I want to obtain a full list of controls inside containers, not a list of containers, then a full list of textboxes, comboboxes, radiobuttons, etc. Sorry if I didn´t express it correctly.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 34919975
Use a recursive routine like this:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        RecurseControls(Me)
    End Sub

    Private Sub RecurseControls(ByVal cont As Control)
        For Each ctl As Control In cont.Controls
            Debug.Print(ctl.Name & ": " & ctl.GetType.ToString)
            If ctl.HasChildren Then
                RecurseControls(ctl)
            End If
        Next
    End Sub

End Class

Open in new window

0
 

Author Comment

by:BemboX
ID: 34920011
Thanks
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

649 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