How to get the selected row values of DevExpress XtraGrid?

前端 未结 7 783
后悔当初
后悔当初 2020-12-03 07:48

Consider the following picture

\"enter

I get the selected row values in the th

7条回答
  •  清歌不尽
    2020-12-03 08:28

    Here is the way that I've followed,

    int[] selRows = ((GridView)gridControl1.MainView).GetSelectedRows();
    DataRowView selRow = (DataRowView)(((GridView)gridControl1.MainView).GetRow(selRows[0]));
    txtName.Text = selRow["name"].ToString();
    

    Also you can iterate through selected rows using the selRows array. Here the code describes how to get data only from first selected row. You can insert these code lines to click event of the grid.

提交回复
热议问题