home *** CD-ROM | disk | FTP | other *** search
- Module Functions
- ' Return the index in a ListControl given a value.
- Function GetIndexFromValue2(ByVal lst As ListControl, ByVal value As String) As Integer
- Dim i As Integer
- For i = 0 To lst.Items.Count - 1
- If lst.Items(i).Value = value Then
- ' we've found the element
- Return i
- End If
- Next
- ' else return not found
- Return -1
- End Function
-
- ' Select the ListControl element with a given value.
- Sub SelectItemFromValue(ByVal lst As ListControl, ByVal value As String)
- Dim i As Integer
- For i = 0 To lst.Items.Count - 1
- If lst.Items(i).Value = value Then
- ' we've found the element - select it and exit.
- lst.SelectedIndex = i
- Exit Sub
- End If
- Next
- End Sub
-
- ' Find a control in a hierarchy of controls.
- Function FindControlRecursive(ByVal ctrl As Control, ByVal id As String) As Control
- ' Exit if this is the control we're looking for.
- If ctrl.ID = id Then Return ctrl
-
- ' Else, look in the hiearchy.
- Dim childCtrl As Control
-
- For Each childCtrl In ctrl.Controls
- Dim resCtrl As Control = FindControlRecursive(childCtrl, id)
- ' Exit if we've found the result
- If Not resCtrl Is Nothing Then Return resCtrl
- Next
- End Function
-
-
- End Module