Back to Devexpress

SpreadsheetControl.SelectedShape Property

windowsforms-devexpress-dot-xtraspreadsheet-dot-spreadsheetcontrol-42425957.md

latest5.2 KB
Original Source

SpreadsheetControl.SelectedShape Property

Gets or sets a shape selected in the active worksheet.

Namespace : DevExpress.XtraSpreadsheet

Assembly : DevExpress.XtraSpreadsheet.v25.2.dll

NuGet Package : DevExpress.Win.Spreadsheet

Declaration

csharp
[Browsable(false)]
public Shape SelectedShape { get; set; }
vb
<Browsable(False)>
Public Property SelectedShape As Shape

Property Value

TypeDescription
Shape

A Shape object. If you assign a shape located in a worksheet that is not active, an exception is raised.

|

Remarks

All shapes in a worksheet are contained in the ShapeCollection, accessible via the Worksheet.Shapes property. Use the SelectedShape property to specify a shape selected in the active worksheet. Images embedded in a worksheet expose the Picture interface which descends from the Shape. So, to specify a picture selected in the active worksheet, you can use the SpreadsheetControl.SelectedPicture property as well as SelectedShape.

You can also select multiple shapes in the worksheet simultaneously. To get or set a list of shapes selected in the active worksheet, use the SpreadsheetControl.GetSelectedShapes or SpreadsheetControl.SetSelectedShapes method.

To select shapes in a specific worksheet of the document loaded in the SpreadsheetControl, use the Worksheet.SelectedPicture, Worksheet.SelectedShape, Worksheet.SetSelectedShapes and Worksheet.GetSelectedShapes members of the corresponding worksheet object.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SelectedShape 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-implement-microsoft-excel-format-painter/CS/WindowsFormsApplication1/FormatPainterProvider.cs#L83

csharp
{
    if (spreadsheetControl.SelectedShape != null || spreadsheetControl.SelectedComment != null)
    {

winforms-spreadsheet-implement-microsoft-excel-format-painter/VB/WindowsFormsApplication1/FormatPainterProvider.vb#L74

vb
Private Sub spreadsheetControl1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
    If spreadsheetControl.SelectedShape IsNot Nothing OrElse spreadsheetControl.SelectedComment IsNot Nothing Then
        biFormatPainter.Enabled = False

See Also

SelectedPicture

SetSelectedShapes(IList<Shape>)

GetSelectedShapes()

SpreadsheetControl Class

SpreadsheetControl Members

DevExpress.XtraSpreadsheet Namespace