Back to Devexpress

Section.ProtectedForForms Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-section-17a7ae22.md

latest2.9 KB
Original Source

Section.ProtectedForForms Property

Gets or sets whether a section is protected for forms (section content is read-only except for form fields).

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
bool ProtectedForForms { get; set; }
vb
Property ProtectedForForms As Boolean

Property Value

TypeDescription
Boolean

true if the section is protected for forms; otherwise, false.

|

Remarks

When a section is protected, you can modify text only in form fields. To protect an entire document, use the Document.Protect method.

Example

The following code snippet loads a document with two sections, turns on form protection for the first section in the document, unprotects the second section, and saves the updated document.

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;

using (var wordProcessor = new RichEditDocumentServer()) {
    wordProcessor.LoadDocument(@"C:\DocumentWithTwoSections.docx", DocumentFormat.Docx);
    wordProcessor.Document.Sections[0].ProtectedForForms = true;
    wordProcessor.Document.Sections[1].ProtectedForForms = false;
    wordProcessor.Document.Protect("", DocumentProtectionType.FillInForms);
    wordProcessor.SaveDocument("DocumentWithTwoSectionsProtected.docx", DocumentFormat.Docx);
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native

Using wordProcessor = New RichEditDocumentServer()
    wordProcessor.LoadDocument("C:\DocumentWithTwoSections.docx", DocumentFormat.Docx)
    wordProcessor.Document.Sections(0).ProtectedForForms = True
    wordProcessor.Document.Sections(1).ProtectedForForms = False
    wordProcessor.Document.Protect("", DocumentProtectionType.FillInForms)
    wordProcessor.SaveDocument("DocumentWithTwoSectionsProtected.docx", DocumentFormat.Docx)
End Using

See Also

Protect Word Documents

Section Interface

Section Members

DevExpress.XtraRichEdit.API.Native Namespace