We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to get information from the selected cells when using cell selection?

Cell selection, just like in Excel, can be enabled by setting SfDataGrid.SelectionUnit as Cell or Any. While selecting cells using cell selection, you can access the selected cells details using the SfDataGrid.GetSelectedCells method. It returns the collection of GridCellInfo.

Here, SfDataGrid is defined with cell selection by setting SelectionUnit as Cell.

XAML

The following code example explains how you can get the selected cells information using SfDataGrid.GetSelectedCells method.

C#

The GridCellInfo class contains the following properties:

RowData- Gets or sets record information of the row.

RowIndex- Gets row index of the selected cell.

Column- Gets or sets the column of the selected cell.

IsDataRowCell- Gets a value indicating whether the selected cell is a data row cell.

IsAddNewRow- Gets a value indicating whether the selected cell is in AddNewRow.

You can use the following helpers to extract information from GridCellInfo:

GridIndexResolver.ResolveToRowIndex- You can use this method to get RowIndex from the Record, GridCellInfo.RowData.

GridIndexResolver.ResolveToRecordIndex- You can use this method to get Record index from the RowIndex, GridCellInfo.RowIndex.

GridIndexResolver.ResolveToGridVisibleColumnIndex- You can use this method to get the visiblecolumn index from the GridColumn index.

SfDataGrid.View.GetPropertyAccessProvider- This method returns IPropertyAccessProvider, that is used to reflect values by passing value and property name.

Refer the following screenshot to get the information of selected cell value.

 

Sample Links:

WPF

WRT
SilverLight

UWP

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
3010 12/10/2014 01/22/2016 Silverlight SfDataGrid 4.5
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.