Version

Working with Selection (XamSpreadsheet)

Purpose

This topic explains the selection feature from developer perspective.

Required background

The following table lists the concept and topics required as a prerequisite to understanding this topic.

Type Content

Concept

Infragistics Excel Engine

Topic Purpose

In this section you will find information that will help you to better understand the object model and the functionalities of the Infragistics Excel Engine .

This topic explains in details the features of the XamSpreadsheet control from developer perspective.

This topic provides an overview of the visual elements of the XamSpreadsheet control.

This topic explains what actions can be performed by the user when selecting worksheet cells.

This topic explains how to configure the selection feature.

Selection Tasks Summary

Selection tasks summary chart

The following table explains briefly the tasks available when working with selection and maps them to the members which are connected with them. Further details are available after the table.

Task Details Property/Event

Obtain the current selection’s cell ranges

Alter selection using a number of methods

Get notified when current selection changes

Obtain Current Selection

Overview

You can obtain the sheet’s current selection using the CellRanges property. It will return a read-only collection of cell ranges that are selected.

Property settings

The following table maps the desired behaviors to the property settings that manage it.

In order to: Use this property: And set it to:

Access cell ranges

Read collection’s items

Example

The following code snippet demonstrates how to add one more selection range (starting from row 4, column 7 and ending with row 6, column 27) to the current selection. The code snippet assumes you have a reference to an XamSpreadsheet instance named "XamSpreadsheet1".

In C#:

this.XamSpreadsheet1.ActiveSelection.AddCellRange(
  new SpreadsheetCellRange(4, 7, 6, 27)
);

In Visual Basic:

Me.XamSpreadsheet1.ActiveSelection.AddCellRange(_
  New SpreadsheetCellRange(4, 7, 6, 27))

Alter Selection Programmatically

Overview

You can alter the sheet selection programmatically using the ActiveSelection property. This property of type SpreadsheetSelection exposes a number of methods for adding, replacing and clearing cell ranges.

Property settings

The following table maps the desired behaviors to the property settings that manage it.

In order to: Use this property: And:

Alter spreadsheet selection

Use the selection altering methods

Selection Changed Notification

Overview

In order for you to be notified when a selection change occurs you can hook on the SelectionChanged event.

Property settings

The following table maps the desired behaviors to the events that manage it.

In order to: Use this event: And:

Be notified when a selection change occurs

SelectionChanged

Attach an event handler to it

Related Content

The following topics provide additional information related to this topic.

Topic Purpose

This topic explains how to configure and perform undo and redo operations with the control.

This topic explains the activation feature from developer perspective.