Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用DataGridView选定的行初始化DataRow对象_C#_Window - Fatal编程技术网

C# 使用DataGridView选定的行初始化DataRow对象

C# 使用DataGridView选定的行初始化DataRow对象,c#,window,C#,Window,Windows c#桌面应用程序 我想用所选的DataGrdView行初始化DataRow对象 如果可能的话,怎么可能 我正在写下面的代码,它给出了编译错误 DataRow dr = (DataRow)DataGridView1.SelectedRows[0]; 谢谢你试试这个 DataRow dr = (dataGridView1.SelectedRows[0].DataBoundItem as DataRowView).Row; 试试这个: DataRow dr = (DataGridV

Windows c#桌面应用程序

我想用所选的
DataGrdView
行初始化
DataRow对象

如果可能的话,怎么可能

我正在写下面的代码,它给出了编译错误

DataRow dr = (DataRow)DataGridView1.SelectedRows[0];
谢谢你试试这个

DataRow dr = (dataGridView1.SelectedRows[0].DataBoundItem as DataRowView).Row;
试试这个:

DataRow dr = (DataGridView1.SelectedRows[0].DataBoundItem as DataRowView).Row;

根据我的浏览器,你比我快17秒:)