Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Protect a Chart Sheet

You can protect a chart sheet to prevent a user from making changes to chart elements. Use the ChartSheet.Protect method to apply protection to a chart sheet. Specify an optional password that should be entered to unprotect a chart sheet.

The ChartSheetProtection enumeration values enable you to specify chart sheet elements to which protection is applied. This example uses the ChartSheetProtection.Default value indicating that protection is applied to both the chart elements and graphic objects on the chart sheet.

// Create a chart sheet containing a pie chart.
ChartSheet chartSheet = workbook.ChartSheets.Add(ChartType.Pie, worksheet["B2:C7"]);

// Protect the chart sheet. Prevent end-users from making changes to chart elements.
if (!chartSheet.IsProtected)
    chartSheet.Protect("password", ChartSheetProtection.Default);

workbook.ChartSheets.ActiveChartSheet = chartSheet;

To remove protection, use the ChartSheet.Unprotect method.