.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

ChartSheet.Protect(String, ChartSheetProtection) Method

Protects chart sheet elements to prevent them from being changed by the user.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v20.2.Core.dll


void Protect(
    string password,
    ChartSheetProtection options
Sub Protect(
    password As String,
    options As ChartSheetProtection


Name Type Description
password String

A string that specifies a password for the chart sheet. If the password is an empty string, the chart sheet can be unprotected without using a password.

options ChartSheetProtection

A ChartSheetProtection enumeration member that allows you to specify chart sheet elements to protect.


If a chart sheet is already protected, the Protect method throws an exception. Check the ChartSheet.IsProtected property before calling the method.


Dim worksheet As Worksheet = workbook.Worksheets("chartTask1")

' Create a chart sheet containing a pie chart.
Dim chartSheet As ChartSheet = workbook.ChartSheets.Add(ChartType.Pie, worksheet("B2:C7"))

' Protect the chart sheet. Prevent end-users from making changes to chart elements.
If Not chartSheet.IsProtected Then
    chartSheet.Protect("password", ChartSheetProtection.Default)
End If

workbook.ChartSheets.ActiveChartSheet = chartSheet
See Also