To make it easier for users to identify the search terms that appear in a gallery of search results, we can highlight the matching search terms by constructing HTML with markup that carries out the highlighting.
To demonstrate, let's take the example of a screen that searches a table of issue details. The name of this table is 'Issue Training', and the structure of the table looks like this.
From within an app, the search screen contains a text input control (TextSearchBox1) that enables the user to search criteria.
A gallery control displays the search results. The pertinent part of the formula in the Items property of the gallery control looks like this:
How to highlight the search terms in the gallery control
Here's how to modify the gallery control to highlight the search term that the user enters. From the item template of the gallery control, we would replace the label with an "HTML text" control, and we would replace the HTMLText property with formula that looks like this:
"<font color=blue>" & TextSearchBox1.Text & "</font>"
This formula substitutes all occurrences of the search text with HTML markup that wraps the search text inside a font tag, with the colour set to blue.
The screenshot beneath shows how the screen looks like when a user enters 'hosp'. Notice how those characters are highlighted in blue in the results.
An adaptation of this technique would be to wrap the search terms inside a span tag and to apply inline CSS. The formula beneath shows how to apply a yellow background colour.
"<span style=""background-color:yellow"">" & TextSearchBox1.Text & "</span>"
ConclusionTo make it easier for users to spot matching search terms in the search
results, we can highlight matching words by building HTML with
markup that carries out the highlighting.