officefileapi-devexpress-dot-spreadsheet-dot-sheetview-c8894f87.md
Returns or specifies whether a sheet is selected in a workbook.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
bool IsSelected { get; set; }
Property IsSelected As Boolean
| Type | Description |
|---|---|
| Boolean |
true if the sheet is selected; otherwise, false.
|
The following example shows how to select all odd sheets in a workbook:
SheetCollection sheets = workbook.Sheets;
for (int i = sheets.Count - 1; i >= 0; i--)
if (i % 2 == 0)
sheets[i].ActiveView.IsSelected = true;
Dim sheets As SheetCollection = workbook.Sheets
For i As Integer = sheets.Count - 1 To 0 Step -1
If i Mod 2 = 0 Then
sheets(i).ActiveView.IsSelected = True
End If
Next i
Use the SheetCollection.ActiveSheet property to specify the active sheet in the document. The IsSelected property value is always true for the active sheet and cannot be changed to false.
The following example retrieves names of selected sheets:
using System.Collections.Generic;
using DevExpress.Utils.Extensions;
using DevExpress.Spreadsheet;
// ...
SheetCollection sheets = workbook.Sheets;
List<string> selectedSheetNames = new List<string>();
sheets.ForEach((sheet) => {
if (sheet.ActiveView.IsSelected)
selectedSheetNames.Add(sheet.Name);
});
Imports System.Collections.Generic
Imports DevExpress.Utils.Extensions
Imports DevExpress.Spreadsheet
' ...
Dim sheets As SheetCollection = workbook.Sheets
Dim selectedSheetNames As New List(Of String)()
sheets.ForEach(Sub(sheet)
If sheet.ActiveView.IsSelected Then
selectedSheetNames.Add(sheet.Name)
End If
End Sub)
See Also