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 access to the selected row's values?
+2
A:
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;
Henk Holterman
2009-05-21 23:30:51
A:
You should be able to directly cast your selected row into the strongly typed row that was bound to the DataGridView.
Dillie-O
2009-05-21 23:31:45
+2
A:
DataRowView currentDataRowView = (DataRowView)dataGridView1.CurrentRow.DataBoundItem
DataRow row = currentDataRowView.Row
Stuart Dunkeld
2009-05-21 23:31:57