如何从DataGridView中

如何从DataGridView中

我正在使用数据绑定(bind)的Windows窗体DataGridView。如何从DataGridView中用户选择的行转到其来源的DataRowDataTable

最佳答案

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/

10-09 00:46