troubleshooting Question

Loop through Form Controls

Avatar of posseke
possekeFlag for Cabo Verde asked on
Visual Basic.NET
7 Comments1 Solution437 ViewsLast Modified:
Hi,

I've been working on a recursive method that loops through every single control in a form, and enables/disables it if needed.
The problem I am having is that I want to disable certain buttons on the BindingNavigator, but none of them are present in the control collection of the BindingNavigator. Is anyone aware of this situation, or do I need to adapt my code? (see below)

The method below searches for a certain control , given its name ('keyword' parameter), starting in a certain topLevelControl (i.e the main form)
It returns true if the control was found, and false if otherwise.

But when i debug the code I can clearly see that the BindingNavigator control contains no subchild controls, even though there are buttons and textboxes on the BindingNavigator.

[CODE]

    Private Function findControlByKey(ByVal topLevelControl As Control, ByVal keyWord As String) As Boolean
        '
        For Each subControl As Control In topLevelControl.Controls
            '
            If subControl.HasChildren = True Then
                '
                If findControlByKey(subControl, keyWord) = True Then
                    Return True
                End If
                '
            Else
                '
                If subControl.Name = keyWord Then
                    '
                    Return True
                    '
                End If
                '
            End If
            '
        Next
        '
        Return False
        '
    End Function

[/CODE]


Any help or suggestions as to approach this in a different manner is greatly appreciated!

Yours truly,

Po$$e

 
ASKER CERTIFIED SOLUTION
DjDezmond

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros