SubTextParts have been introduced in version X13 (23.0) as a new document element to realize the new MailMerge merge block concept. But this element can be used for other tasks as well.

A SubTextPart object represents a user-defined part of a TX Text Control document with a specific Name and ID. The following code can be used to convert the currently selected text into a SubTextPart:

SubTextPart part = new SubTextPart("protected", 1);
part.HighlightMode = HighlightMode.Always;
textControl1.SubTextParts.Add(part);
view raw Form1.cs hosted with ❤ by GitHub

The Name property is set to protected which is simply an identifier in this sample that defines that this SubTextPart should be protected from user changes.

When the caret enters the SubTextPart, the SubTextPartEntered event is used to set the EditMode property of TX Text Control to ReadAndSelect.

On leaving the SubTextPart, the SubTextPartLeft event is used to switch back to edit mode.

private void textControl1_SubTextPartEntered(object sender, SubTextPartEventArgs e)
{
if (e.SubTextPart.Name == "protected")
textControl1.EditMode = EditMode.ReadAndSelect;
}
private void textControl1_SubTextPartLeft(object sender, SubTextPartEventArgs e)
{
textControl1.EditMode = EditMode.Edit;
}
view raw Form1.cs hosted with ❤ by GitHub

This is just one more application for this new element. This element can be used to store additional information, comments or to highlight text parts permanently in different colors.