我有一个绑定到DataGridView的DataTable。我在DGV中启用了FullRowSelect。有没有一种方法可以将所选行作为DataRow,这样我就可以强类型访问所选行的值?
发布于 2009-05-21 23:30:51
我不确定如何在没有BindingSource的情况下做到这一点,下面是如何用它做到的:
var drv = bindingSoure1.Current as DataRowView;
if (drv != null)
var row = drv.Row as MyRowType;
发布于 2009-05-21 23:31:58
DataRowView currentDataRowView = (DataRowView)dgv1.CurrentRow.DataBoundItem
DataRow row = currentDataRowView.Row
发布于 2009-05-21 23:31:45
您应该能够将所选行直接转换为绑定到DataGridView的强类型行。
https://stackoverflow.com/questions/895778
复制相似问题