Using TX Text Control X15, documents can be protected by restricting the formatting and editing of content. When protecting a document, it is possible to define whether the document is completely locked or formatting can be applied.

Technically, the document gets encrypted with a password. When this encrypted document is loaded, it is restricted or set to read-only. In order to edit the document, the password needs to be entered.

Document protection diagram

The following code sets 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.
to UsePassword which can be only combined with EditMode.ReadAndSelect using the bitwise or operator.

textControl1.EditMode = EditMode.UsePassword | EditMode.ReadAndSelect;
textControl1.Save("encrypted-document.tx", StreamType.InternalUnicodeFormat);
view raw tx.cs hosted with ❤ by GitHub

When the document is loaded and the EditMode property is set to Edit, a dialog box to enter a password is opened automatically:

textControl1.Load("encrypted-document.tx", StreamType.InternalUnicodeFormat);
textControl1.EditMode = EditMode.Edit;
view raw tx.cs hosted with ❤ by GitHub

If the entered password matches the password that has been used to encrypt the document, the document can be edited again.

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.

How these regions can be inserted and how to define the current user will be explained in one of the next blog entries. Stay tuned!