Back to Devexpress

How to: Show and Hide a Worksheet

wpf-16319-controls-and-libraries-spreadsheet-examples-worksheets-how-to-show-and-hide-a-worksheet.md

latest1.7 KB
Original Source

How to: Show and Hide a Worksheet

  • Jun 07, 2019
  • 2 minutes to read

This example demonstrates how to manage worksheet visibility in a workbook. To do this, use the following properties.

Note

A workbook must always contain at least one visible worksheet.

View Example

csharp
// Hide the "Sheet2" worksheet and prevent end-users from unhiding it via the user interface.
// To make this worksheet visible again, use the Worksheet.Visible property.
workbook.Worksheets["Sheet2"].VisibilityType = WorksheetVisibilityType.VeryHidden;

// Hide the "Sheet3" worksheet. 
// In this state, the worksheet can be unhidden via the user interface.
workbook.Worksheets["Sheet3"].Visible = false;
vb
' Hide the "Sheet2" worksheet and prevent end-users from unhiding it via the user interface.
' To make this worksheet visible again, use the Worksheet.Visible property.
workbook.Worksheets("Sheet2").VisibilityType = WorksheetVisibilityType.VeryHidden

' Hide the "Sheet3" worksheet. 
' In this state, the worksheet can be unhidden via the user interface.
workbook.Worksheets("Sheet3").Visible = False

After executing the code above, the “Sheet2” worksheet is hidden, and cannot be accessed by an end-user in SpreadsheetControl. The “Sheet3” worksheet is also hidden, but its visibility can be restored by an end-user.