windowsforms-devexpress-dot-xtraspreadsheet-dot-spreadsheetcontrol-5300a939.md
Gets the worksheet that is currently displayed in the SpreadsheetControl.
Namespace : DevExpress.XtraSpreadsheet
Assembly : DevExpress.XtraSpreadsheet.v25.2.dll
NuGet Package : DevExpress.Win.Spreadsheet
[Browsable(false)]
public Worksheet ActiveWorksheet { get; }
<Browsable(False)>
Public ReadOnly Property ActiveWorksheet As Worksheet
| Type | Description |
|---|---|
| Worksheet |
A Worksheet object that specifies the active worksheet.
|
A document loaded in the SpreadsheetControl is a workbook that consists of one or more worksheets (WorksheetCollection). A worksheet that is currently displayed in the SpreadhsheetControl and available to be modified by an end-user is called an active worksheet and returned by the ActiveWorksheet property.
You can also access and change an active worksheet in code using the WorksheetCollection.ActiveWorksheet property. An end-user can switch between worksheets using the SpreadsheetControl’s Sheet Tab Selector. Before and after an active worksheet is changed via the control’s UI, the SpreadsheetControl.ActiveSheetChanging and SpreadsheetControl.ActiveSheetChanged events are raised, respectively.
To set an active worksheet within a workbook, assign the corresponding Worksheet object to the WorksheetCollection.ActiveWorksheet property.
// Set the second worksheet ("Sheet2") as the active worksheet.
workbook.Worksheets.ActiveWorksheet = workbook.Worksheets["Sheet2"];
' Set the second worksheet ("Sheet2") as the active worksheet.
workbook.Worksheets.ActiveWorksheet = workbook.Worksheets("Sheet2")
The following code snippets (auto-collected from DevExpress Examples) contain references to the ActiveWorksheet 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.
winforms-spreadsheet-bind-to-ms-sql-server-database/CS/SuppliersExample/Form1.cs#L41
return;
Worksheet sheet = spreadsheetControl1.ActiveWorksheet;
string cellReference = cell.GetReferenceA1();
winforms-spreadsheet-use-custom-cell-editors/CS/DevAVInvoicing/Form1.cs#L115
void EnableControls() {
Worksheet sheet = spreadsheetControl1.ActiveWorksheet;
if (sheet.Name == "Invoice") {
winforms-spreadsheet-use-formula-engine/CS/FormulaEngineTest/Form1.cs#L34
contextCell = spreadsheetControl1.ActiveCell;
contextSheet = spreadsheetControl1.ActiveWorksheet;
}
winforms-spreadsheet-control-create-a-data-entry-form/CS/DataEntryFormSample/MainForm.cs#L35
private void BindCustomEditors() {
var sheet = spreadsheetControl1.ActiveWorksheet;
// Assign custom editors to worksheet cells.
winforms-spreadsheet-use-cell-range-as-data-source/CS/RangeDataSource/Form1.cs#L29
RangeDataSourceOptions options = new RangeDataSourceOptions();
Worksheet sheet = spreadsheetControl1.ActiveWorksheet;
CellRange dataRange = sheet.Selection;
winforms-spreadsheet-bind-to-ms-sql-server-database/VB/SuppliersExample/Form1.vb#L43
If cell Is Nothing Then Return
Dim sheet As Worksheet = spreadsheetControl1.ActiveWorksheet
Dim cellReference As String = cell.GetReferenceA1()
winforms-spreadsheet-use-custom-cell-editors/VB/DevAVInvoicing/Form1.vb#L106
Private Sub EnableControls()
Dim sheet As Worksheet = spreadsheetControl1.ActiveWorksheet
If Equals(sheet.Name, "Invoice") Then
winforms-spreadsheet-use-formula-engine/VB/FormulaEngineTest/Form1.vb#L32
contextCell = spreadsheetControl1.ActiveCell
contextSheet = spreadsheetControl1.ActiveWorksheet
End Sub
winforms-spreadsheet-control-create-a-data-entry-form/VB/DataEntryFormSample/MainForm.vb#L30
Private Sub BindCustomEditors()
Dim sheet = spreadsheetControl1.ActiveWorksheet
winforms-spreadsheet-use-cell-range-as-data-source/VB/RangeDataSource/Form1.vb#L33
Dim options As RangeDataSourceOptions = New RangeDataSourceOptions()
Dim sheet As Worksheet = spreadsheetControl1.ActiveWorksheet
Dim dataRange As CellRange = sheet.Selection
See Also