New to Telerik UI for WinForms? Download free 30-day trial

Formatting Blocks

The RadAutoCompleteBox allows appearance customization of each instance of ITextBlock. This can be easily achieved by subscribing to the FormattingTextBlock event:

void radAutoCompleteBox1_TextBlockFormatting(object sender, TextBlockFormattingEventArgs e)
{
    TokenizedTextBlockElement token = e.TextBlock as TokenizedTextBlockElement;
    if (token != null)
    {
        token.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
        token.BackColor = Color.Yellow;
    }
}

Private Sub radAutoCompleteBox1_TextBlockFormatting(sender As Object, e As TextBlockFormattingEventArgs)
    Dim token As TokenizedTextBlockElement = TryCast(e.TextBlock, TokenizedTextBlockElement)
    If token IsNot Nothing Then
        token.GradientStyle = Telerik.WinControls.GradientStyles.Solid
        token.BackColor = Color.Yellow
    End If
End Sub

Figure 1: Items with yellow background.

WinForms RadAutoCompleteBox Items With Yellow Background

Note that the event occurs when the text blocks are repositioned. This happens in different cases - editing, control resizing and etc. Hence, you should subscribe to the event before initializing the Text property.

See Also

In this article