Back to Devexpress

SheetView.IsSelected Property

officefileapi-devexpress-dot-spreadsheet-dot-sheetview-c8894f87.md

latest2.7 KB
Original Source

SheetView.IsSelected Property

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

Declaration

csharp
bool IsSelected { get; set; }
vb
Property IsSelected As Boolean

Property Value

TypeDescription
Boolean

true if the sheet is selected; otherwise, false.

|

Remarks

Select Sheets

The following example shows how to select all odd sheets in a workbook:

csharp
SheetCollection sheets = workbook.Sheets;
for (int i = sheets.Count - 1; i >= 0; i--)
    if (i % 2 == 0)
        sheets[i].ActiveView.IsSelected = true;
vb
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.

Retrieve Selected Sheets

The following example retrieves names of selected sheets:

csharp
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);
});
vb
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

SheetView Interface

SheetView Members

DevExpress.Spreadsheet Namespace