Skip to main content

ChartOptions.Protection Property

Gets or sets the chart protection.

Namespace: DevExpress.Spreadsheet.Charts

Assembly: DevExpress.Spreadsheet.v24.1.Core.dll

NuGet Package: DevExpress.Spreadsheet.Core

Declaration

ChartProtection Protection { get; set; }

Property Value

Type Description
ChartProtection

A ChartProtection enumeration value containing protection options.

Available values:

Name Description
None

Specifies that a chart is not protected.

ChartObject

Specifies that an end-user is not allowed to edit a chart.

Data

Specifies that an end-user is not allowed to change chart data links.

Formatting

Specifies that an end-user is not allowed to format chart elements.

Selection

Specifies that an end-user is not allowed to select chart elements.

UserInterface

Specifies that a chart cannot be modified from the user interface.

All

Specifies that an end-user is not allowed to select a chart, modify its elements and change chart data references.

Property Paths

You can access this nested property as listed below:

Object Type Path to Protection
ChartObject
.Options .Protection

Remarks

Use the Protection property to prevent the chart from being modified by the user. Currently, members of the ChartProtection enumeration do not influence the chart protection. Whatever value you select, the chart will be completely locked, so that an end-user cannot select or modify it through the user interface. However, you can access the protected chart in code and apply desired changes programmatically.

Example

The following example demonstrates how to create a clustered column chart and apply chart protection using the ChartOptions.Protection property.

View Example

Worksheet worksheet = workbook.Worksheets["chartTask3"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.ColumnClustered, worksheet["B2:D4"]);
chart.TopLeftCell = worksheet.Cells["H2"];
chart.BottomRightCell = worksheet.Cells["N14"];

// Specify the chart style.
chart.Style = ChartStyle.ColorDark;

// Apply the chart protection.
chart.Options.Protection = ChartProtection.All;

The following code snippets (auto-collected from DevExpress Examples) contain references to the Protection property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also