Search code examples
c#devexpressgridcontroldevexpress-gridcontrol

How to check if there is any selected row in gridControl?


I'm beginner in using DevExpress tools. I can not find any property, that shows the gridControl's row selections state, to my if statement.

Any suggestion?


Solution

  • You can use the ColumnView.SelectedRowsCount property to return the number of selected rows/cards.

    if (gridView1.SelectedRowsCount > 0) {    
        int[] selectedRowHandles = gridView1.GetSelectedRows();
        for (int i = 0; i < selectedRowHandles.Length; i++) {
          //... object rowObject = gridView1.GetRow(selectedRowHandles[i]);
        }
    }