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 TX Text Control .NET for Windows Forms
TXTextControl Namespace
EditableRegion Class
An EditableRegion object represents an editable region in a TX Text Control document.
represents an editable region in a protected document. When the TXTextControl.TextControl.EditMode property TX Text Control .NET for Windows Forms
TXTextControl Namespace
TextControl Class
EditMode Property
Gets or sets a value indicating whether the document's text is protected, or can be freely edited and formatted.
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 TX Text Control .NET for Windows Forms
TXTextControl Namespace
EditableRegion Class
UserName Property
Gets or sets the name of the user who can edit the region.
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 TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
EditableRegion Class
EditableRegion Constructor
Initializes a new instance of the EditableRegion class.
is the TXTextControl.EditableRegion.UserName property TX Text Control .NET for Windows Forms
TXTextControl Namespace
EditableRegion Class
UserName Property
Gets or sets the name of the user who can edit the region.
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);
view raw tx.cs hosted with ❤ by GitHub

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);
view raw tx.cs hosted with ❤ by GitHub

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);
view raw tc.cs hosted with ❤ by GitHub

After loading the document, the TXTextControl.TextControl.UserNames property TX Text Control .NET for Windows Forms
TXTextControl Namespace
TextControl Class
UserNames Property
Gets or sets a list of names specifying users who have access to editable regions.
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);
view raw tx.cs hosted with ❤ by GitHub

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