检索数据网格的选定行值 [英] Retrieving Selected Row values of a DataGrid

查看:66
本文介绍了检索数据网格的选定行值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图重新获得我的数据网格的选定行值.但是即使我选择多个行,也只能获得一行..
请在下面找到我的代码

I was trying to retirve the selected row values of my datagrid.. But gettting only one row even if i select more than one..
please find my code below

foreach (DataGridViewRow dataGridViewRow in myDataGridView.SelectedRows)
{                addNewResourceDictionary.Add(dataGridViewRow.Cells[0].Value.ToString(), dataGridViewRow.Cells[1].Value.ToString()); ;
}





请告知





please advise

推荐答案

foreach (DataGridViewRow dGRow in myDataGridView.SelectedRows)
            {

addNewResourceDictionary.Add(dataGridViewRow.Rows[dGRow].Cells[0].Value.ToString(), dataGridViewRow.Rows[dGRow].Cells[1].Value.ToString()); 

            }


这篇关于检索数据网格的选定行值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆