Expand Minimize

DataGrid::SelectedCells Property

Gets the list of cells that are currently selected.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public:
property IList<DataGridCellInfo>^ SelectedCells {
	IList<DataGridCellInfo>^ get ();
}

Property Value

Type: System.Collections.Generic::IList<DataGridCellInfo>
The list of cells that are currently selected.

There are three selection modes for DataGrid. The selection mode is set with the SelectionUnit property. Depending on the SelectionUnit, SelectedCells or SelectedItems will contain a collection of selected items as defined in the following table.

DataGridSelectionUnit value

SelectedCells value

SelectedItems value

Cell

Collection of selected cells

Empty

FullRow

Collection of cells in the selected rows

Collection of selected rows

CellOrRowHeader

Collection of selected cells, including all cells in a selected row

Collection of selected rows or empty if no full rows are selected

When a cell is selected, the DataGridCell::Selected event is raised, the DataGridCell::IsSelected property is set to true, and the cell is added to the SelectedCells collection.

When a row is selected, the DataGridRow::Selected event is raised, the DataGridRow::IsSelected property is set to true, and the row is added to the SelectedItems collection.

When the selection changes, the SelectionChanged and SelectedCellsChanged events are raised if the new or old selection contains a row. The SelectionChanged event is not raised if the new or old selection contains only cells.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft