New to Telerik UI for WinFormsStart a free 30-day trial

Formatting Blocks

Updated over 1 year ago

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

Subscribing to TextBlockFormatting event

C#
            
this.radTextBoxControl1.TextBlockFormatting += this.OnTextBlockFormatting;
this.radTextBoxControl1.Text = "This is important text.";

The TextBlockFormatting event handler

C#
        
private void OnTextBlockFormatting(object sender, Telerik.WinControls.UI.TextBlockFormattingEventArgs e)
{
    TextBlockElement textBlock = e.TextBlock as TextBlockElement;
    if (textBlock != null && e.TextBlock.Text == "important")
    {
        textBlock.ForeColor = Color.Red;
    }
}

WinForms RadTextBoxControl Formatting Blocks

Notice 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
See Also
Not finding the help you need?
Contact Support