Products Technologies Demo Docs Blog Support Company

X15: Protected Documents Explained Simply - Part II

This article explains the document protection feature in an easy to understand way focused on the editable regions.

X15: Protected Documents Explained Simply - Part II

In the last blog entry, the new document protection feature of TX Text Control X15 has been explained. Documents can be protected by restricting the formatting and editing of content.

Editable regions are exceptions within protected documents to provide specific users permissions to edit these regions while the rest of the document is read-only.

The TXTextControl.EditableRegion class represents an editable region in a protected document. When the TXTextControl.TextControl.EditMode property of TX Text Control has been set to ReadAndSelect, editable regions can still be edited, either by everyone or depending on the TXTextControl.EditableRegion.UserName property by a certain user.

The following code inserts a new editable region at the currently selected text. The first parameter in the TXTextControl.EditableRegion constructor is the TXTextControl.EditableRegion.UserName property which specifies the name of the user who can edit the region. In the following code, the UserName is null which indicates that every user can edit this region:

EditableRegion region = new EditableRegion(null, 10);
textControl1.EditableRegions.Add(region);

In the next code snipped, an editable region is added at a specific selection range for the user developer@textcontrol.com. The word Text is now editable for this specific user:

textControl1.Text = "TX Text Control";
EditableRegion region = new EditableRegion("developer@textcontrol.com", 10, 4, 4);
textControl1.EditableRegions.Add(region);

The document can now be protected and saved using the following code:

textControl1.EditMode = EditMode.UsePassword | EditMode.ReadAndSelect;
textControl1.Save("encrypted-document.tx", TXTextControl.StreamType.InternalUnicodeFormat);

After loading the document, the TXTextControl.TextControl.UserNames property can be used to define a list of names specifying users who have access to editable regions. In this sample, we grant access for the user developer@textcontrol.com:

textControl1.UserNames = new string[] { "developer@textcontrol.com" };
textControl1.Load("encrypted-document.tx", StreamType.InternalUnicodeFormat);

Protecting documents with TX Text Control

This is only one of many great new features of TX Text Control X15. Download your trial version today and test this on your own.

Learn more

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Also See

This post references the following in the documentation:

  • TXTextControl.EditableRegion Class
  • TXTextControl.EditableRegion.UserName Property
  • TXTextControl.TextControl.EditMode Property

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 FormsDocument ProtectionRelease

X15: Protected Documents Explained Simply

This article explains the document protection feature in an easy to understand way.


ASP.NETWindows FormsWPF

TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 3 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ASP.NETWindows FormsWPF

TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version

TX Text Control 33.0 Service Pack 2 is now available, offering important updates and bug fixes for all platforms. If you use TX Text Control in your document processing applications, this service…


ActiveXASP.NETWindows Forms

Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5

TX Text Control 33.0 Service Pack 1 and TX Text Control 32.0 Service Pack 5 have been released, providing important updates and bug fixes across platforms. These service packs improve the…


ASP.NETWindows FormsWPF

The Wait is Over: TX Text Control for Linux is Officially Here

We are very excited to announce the release of TX Text Control 33.0 which includes the long awaited Linux version of TX Text Control. This version allows you to integrate TX Text Control into your…