|
-
Apr 7th, 2004, 11:16 AM
#1
Thread Starter
Junior Member
how to Find a control in a form.
Hi, I just tried to write a control search function tbut I'm not having much success.
I need it to be able to iterate through all the controls on a forum and all the container controls (group boxes, panels, etc) within and return a reference to the control I'm searching for
this is what I have so far. The problem is that Groupbox and Panel are not considered a ContainerControl so it just skips past that condition.
Public Function FindControl(ByRef Controls As System.Windows.Forms.Control.ControlCollection, ByVal strControlName As String) As Forms.Control
Dim objTemp As Forms.Control
Dim objReturnControl As Forms.Control
For Each objTemp In Controls
If TypeOf (objTemp) Is ContainerControl Then
objReturnControl = FindControl(objTemp.Controls, strControlName)
If Not objReturnControl Is Nothing Then
Return objReturnControl
End If
ElseIf objTemp.Name = strControlName Then
Return objTemp
End If
Next
Return Nothing
End Function
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
|