New to Telerik UI for WinForms? Start 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;
}
}

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.