Sub resultsULV_ContentFiller(ItemID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)
...
Dim nameLabel As Label = LayoutPanel.GetView(1)
nameLabel.Text = highlightTextInString(c.buildPageNameInCurrent(tempPage), searchField.Text)
Dim noteLabel As Label = LayoutPanel.GetView(2)
noteLabel.Text = highlightTextInString(getSurroundingText(tempPage.pageNote, searchField.Text, noteLabel), searchField.Text)
End Sub
Sub highlightTextInString(bodyText As String, searchText As String) As RichString
Dim rs As RichString
rs.Initialize(bodyText)
Dim startIndex As Int = bodyText.ToLowerCase.IndexOf(searchText.ToLowerCase)
If startIndex > -1 Then 'match found
Dim endIndex As Int = startIndex + searchText.Length
rs.BackColor(c.COLOR_HIGHLIGHT, startIndex, endIndex)
End If
Return rs
End Sub