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

811 Views Asked by At

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?

2

There are 2 best solutions below

0
DmitryG On BEST ANSWER

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]);
    }
}
0
amir bahmanzadegan On

Each Gridcontrol has a view , if your name the view for example Tableview then you can handle it easy, if you select a row it will return row index if no row selected it will return minus row number:

    int clickedRowHandle = Tableview.FocusedRowHandle;

                if (clickedRowHandle < 0)
                {
                    return;
                }else{
                     
                  //Do the action ...
                }