我有一个
Dictionary<string, DataGridViewColumn> junctionTableDependencies = new Dictionary<string, DataGridViewColumn>();
我想使用rows属性遍历字典的值,这些值是单元格的某个值的列,但似乎我没有它
foreach(DataGridViewColumn searchCol in junctionTableDependencies.Values)
foreach(DataGridViewRow row in **searchCol**.)
if(value==row.Cells[0].Value.ToString())
如何在没有 row.Cells [0] 的情况下垂直遍历列?
答案 0 :(得分:0)
您拥有DataGridViewColumn
,因此您需要找到它所属的DataGridView
,然后枚举找到的网格的行:
foreach(DataGridViewColumn searchCol in junctionTableDependencies.Values)
{
foreach(DataGridViewRow thisRow in searchCol.DataGridView.Rows)
{
var value = thisRow.Cells[searchCol.Name];
if (value == "whateverYouNeed")
{
// Code...
}
}
}