Skip to main content

Obtaining Selected Rows and Cells

#Obtaining Selected Rows

Selected rows can be obtained using the DataControlBase.SelectedItems property. This property represents a collection that provides indexed access to selected rows. To obtain selected row handles, use the DataControlBase.GetSelectedRowHandles method.

#Obtaining Selected Cells

Selected cells can be obtained using the TableView.GetSelectedCells method. This method returns an array of GridCell objects that contain cell coordinates (row and column).

#Example: How to Process Selected Rows

This example shows how to process selected rows and unselect rows where the UnitPrice is less than '$10'.


private void ProcessSelectedRows(GridControl gridControl) {
    GridViewBase view = gridControl.View as GridViewBase;
    view.BeginSelection();
    foreach (int rowHandle in view.GetSelectedRowHandles()) {
        if (Convert.ToDouble(gridControl.GetCellValue(rowHandle, "UnitPrice")) < 10)
            view.UnselectRow(rowHandle);
    }
    view.EndSelection();
}