|
-
Oct 18th, 2008, 12:44 AM
#1
Thread Starter
Junior Member
Problem with enumerating all the child controls
Hi all,
Am new to VB.Net.Am able to enumerate all the child controls of any parent window which is currently active... But its again and again calling itself untill that parent window is active.
I wan it to be like, once a new parent window is active, it should find all the child controls and then it should stop untill my next parent window is active.
Is there any way to find the total no. of child controls in the active window?
Is there any way to do it?
Please anyone help me.........
Thanks in advance......
Last edited by kalagammaii; Oct 18th, 2008 at 12:51 AM.
-
Oct 18th, 2008, 01:31 AM
#2
Re: Problem with enumerating all the child controls
You're in the wrong section of the forum.
This is VB6.
Maybe one of the moderators will move it for you.
-
Oct 18th, 2008, 12:59 PM
#3
Re: Problem with enumerating all the child controls
Thread moved from 'VB6 and Earlier' forum to VB.Net (VB2002 and later) forum
(this would have been done much sooner if you had clicked the "report" icon to the left of the post )
-
Oct 18th, 2008, 02:21 PM
#4
Re: Problem with enumerating all the child controls
 Originally Posted by si_the_geek
Thread moved from 'VB6 and Earlier' forum to VB.Net (VB2002 and later) forum
(this would have been done much sooner if you had clicked the "report" icon to the left of the post  )
Didn't know that one, I thought it was for tattling on ppl
-
Oct 18th, 2008, 02:36 PM
#5
Hyperactive Member
Re: Problem with enumerating all the child controls
If I understand you I think you wish to determine all the controls on a given form as well as the children of the children all the way down. If so then you could do something like this:
Code:
Private Sub MakeControlList()
Dim controls As List(Of Control)
controls = New List(Of Control)
EnumerateControls(controls, Me)
Me.ListBox1.Items.AddRange(controls.ToArray())
Me.ListBox1.DisplayMember = "Name"
End Sub
Private Sub EnumerateControls(ByVal controls As List(Of Control), ByVal child As Control)
Dim c As Control
For Each c In child.Controls
controls.Add(c)
EnumerateControls(controls, c)
Next
End Sub
The list 'controls' will contain a recursive list of all the controls on the form. You can call that anytime on a form to get the list. You may want to consider a different structure such as a tree if you want to preserve the parent/child relationships.
-
Oct 19th, 2008, 10:35 PM
#6
Thread Starter
Junior Member
Re: Problem with enumerating all the child controls
I wan it not only for my form, i wan it for any window which is currently active.
but the below mentioned statements can get the controls number only for the form.
EnumerateControls(controls, Me)
Me.ListBox1.Items.AddRange(controls.ToArray())
Me.ListBox1.DisplayMember = "Name"
Please help me out to get it for all the active windows.
Thanks in advance.
-
Oct 19th, 2008, 11:16 PM
#7
Hyperactive Member
Re: Problem with enumerating all the child controls
sorry I didn't understand. do you mean from all active windows outside of your program?
-
Oct 19th, 2008, 11:19 PM
#8
Thread Starter
Junior Member
Re: Problem with enumerating all the child controls
Ya. All active windows outside my program.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|