richEditControl just like this richEditControl1.Document.Protect("", DevExpress.XtraRichEdit.API.Native.DocumentProtectionType.AllowComments);
But spreadsheetControl can't
spreadsheetControl1.Document.Protect("", DevExpress.XtraRichEdit.API.Native.DocumentProtectionType.AllowComments); spreadsheetControl
Yulia (DevExpress Support)6 days ago
Hello,
The Worksheet.Protect method provides a set of available actions to be restricted, similar to the ones specified by the "Protect Sheet" dialog in MS Office Excel. So, the SpreadsheetControl does not provide a special option to allow only editing comments in a document. Please refer to the Protection help topic to learn more regarding the SpreadsheetControl's Protection feature.
To achieve the goal, you can call the Worksheet.Protect method and allow the SelectLockedCells, SelectUnlockedCells and Objects actions. The Objects parameter also allows editing charts and pictures in the document. If you wish to prohibit these actions, set DocumentCapabilities.Charts and DocumentCapabilities.Pictures to DocumentCapability.Disabled (see the attached video).
Here is a sample code snippet that demonstrates this approach:
[C#]Open in popup window
private void CustomProtect() { spreadsheetControl.Options.DocumentCapabilities.Charts = DocumentCapability.Disabled; spreadsheetControl.Options.DocumentCapabilities.Pictures = DocumentCapability.Disabled; spreadsheetControl.ActiveWorksheet.Protect("123", WorksheetProtectionPermissions.Default | WorksheetProtectionPermissions.Objects); } private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { CustomProtect(); }
Note that it will be necessary to enable the DocumentCapabilities.Charts and DocumentCapabilities.Pictures properties manually after a worksheet becomes unprotected.