How to: Show and Hide a Worksheet
- 2 minutes to read
Set this property to false to hide a worksheet. To make a worksheet visible again, you can set the Visible property to true or the Worksheet.VisibilityType property to the WorksheetVisibilityType.Visible enumeration member. End-users can show a hidden worksheet via the SpreadsheetControl user interface.
Setting this property to WorksheetVisibilityType.Hidden is equivalent to setting the Worksheet.Visible property to false - the hidden worksheet can be shown again by end-users via the SpreadsheetControl user interface.
The VisibilityType property also allows you to hide a worksheet so that it becomes impossible for end-users to access this worksheet. To do this, mark the worksheet as “very hidden” by setting the VisibilityType property to WorksheetVisibilityType.VeryHidden. To show the worksheet again, set the Visible property to true or VisibilityType to WorksheetVisibilityType.Visible.
A workbook must always contain at least one visible worksheet.
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spreadsheetcontrol-api-e4655
// 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.