How Do I Get the Selected DataRow in a DataGridView?

前端 未结 7 1018
我寻月下人不归
我寻月下人不归 2021-01-17 09:00

I have a DataTable bound to a DataGridView. I have FullRowSelect enabled in the DGV. Is there a way to get the selected row as a DataRow so that I can get strongly typed a

7条回答
  •  伪装坚强ぢ
    2021-01-17 09:00

    I'm not sure how to do it w/o a BindingSource, here is how to do it with one:

    var drv = bindingSoure1.Current as DataRowView;
    if (drv != null)
      var row = drv.Row as MyRowType;
    

提交回复
热议问题