Highlighting matched text

11 Jul 20231 minute to read

Highlight matching characters in a suggestion list to pick an item with more clarity. There are two ways to highlight the matching text:

  • First Occurrence

  • Multiple Occurrence

The text highlight can be indicated with various customizing styles by enabling the below properties. They are

  • HighlightedTextColor - sets the color of the highlighted text for differentiating the highlighted characters.

  • HighlightedTextFontTypeFace - sets the FontAttributes of the highlighted text.

First Occurrence

It highlights the first position of the matching characters in the suggestion list.

countryAutoComplete.SuggestionMode = SuggestionMode.StartsWith;
countryAutoComplete.TextHighlightMode = OccurrenceMode.FirstOccurrence; 
countryAutoComplete.HighlightedTextColor = Color.Blue; 
countryAutoComplete.HighlightedTextFontTypeFace = TypefaceStyle.Bold;


The default Color of HighlightedTextColor is Red.
The default FontAttribute of HighlightedTextFontTypeFace is None.

First Occurrence AutoComplete Image

Multiple Occurrence

It highlights the matching character that are present everywhere in the suggestion list for Contains case in SuggestionMode.

countryAutoComplete.SuggestionMode = SuggestionMode.Contains;
countryAutoComplete.TextHighlightMode = OccurrenceMode.MultipleOccurrence;
countryNameAutoComplete.HighlightedTextColor = Color.Red; 
countryNameAutoComplete.HighlightedTextFontTypeFace = TypefaceStyle.Bold;

Multiple Occurrence AutoComplete Image