Products Technologies Demo Docs Blog Support Company

Use SubTextParts to Protect Document Parts

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: The Name property is set to protected which is simply an identifier in this sample that defines that this…

Use SubTextParts to Protect Document Parts

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);

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;
}

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.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Windows Forms

Text Control combines the power of a reporting tool and an easy-to-use WYSIWYG word processor - fully programmable and embeddable in your Windows Forms application. TX Text Control .NET for Windows Forms is a royalty-free, fully programmable rich edit control that offers developers a broad range of word processing features in a reusable component for Visual Studio.

See Windows Forms products

Related Posts

Windows FormsWPF.NET

Create a Table of Contents in Windows Forms using C#

This article explains how to create a table of contents in Windows Forms using the ribbon or programmatically. Creating a table of contents is required to organize large documents.


ASP.NETWindows FormsWPF

Official TX Text Control .NET Sample Applications Are Now Hosted on GitHub

This article gives a quick overview of the new repositories, their structure and our plans for the future.


Windows FormsList.NET

Two Ways to Restart Numbered Lists in TX Text Control

In TX Text Control, numbered lists are continued by default and need to be reset when required. There is more than one way if you want to restart numbered lists in a document. In this article, two…


Windows FormsSampleShortcuts

Zoom Tricks: Disabling CTRL + MOUSE WHEEL and More

This article shows how to disable CTRL + MOUSE WHEEL, implement zooming with keyboard and reset the zoom factor to its default value.


Windows FormsSampleTX Spell .NET

AutoCorrect Using TX Text Control and TX Spell .NET

AutoCorrect can be very annoying on a smartphone - we all know this. But if you are used to it and then start typing on a computer keyboard, you are missing this time saving feature. TX Spell .NET…