我正在使用数据绑定(bind) Windows 窗体 DataGridView
。如何从 DataGridView
中用户选择的行转到作为其来源的 DataTable
的 DataRow
?
最佳答案
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/