Back to Devexpress

How to: Set an Active Worksheet

windowsforms-15358-controls-and-libraries-spreadsheet-examples-worksheets-how-to-set-an-active-worksheet.md

latest1.8 KB
Original Source

How to: Set an Active Worksheet

  • Apr 22, 2022

To set an active worksheet within a workbook, assign the corresponding Worksheet object to the WorksheetCollection.ActiveWorksheet property.

View Example

csharp
// Set the second worksheet ("Sheet2") as the active worksheet.
workbook.Worksheets.ActiveWorksheet = workbook.Worksheets["Sheet2"];
vb
' Set the second worksheet ("Sheet2") as the active worksheet.
workbook.Worksheets.ActiveWorksheet = workbook.Worksheets("Sheet2")

The image below shows the worksheet that is set as the active worksheet in a workbook (“Sheet2”).

The SpreadsheetControl.ActiveSheetChanging and SpreadsheetControl.ActiveSheetChanged events are raised before and after the active worksheet is changed via the control’s Sheet Tab Selector, respectively.

See Also

Worksheets in Spreadsheet Documents