我正在使用数据绑定(bind)的Windows窗体DataGridView
。如何从DataGridView
中用户选择的行转到其来源的DataRow
的DataTable
?
最佳答案
DataRow row = ((DataRowView)DataGridViewRow.DataBoundItem).Row
假设您绑定(bind)了一个普通的
DataTable
。MyTypedDataRow row = (MyTypedDataRow)((DataRowView)DataGridViewRow.DataBoundItem).Row
假设您已绑定(bind)类型化数据表。
有关更多信息,请参见article on MSDN。
关于c# - 如何从DataGridView中的一行获取DataRow,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1822314/