0

如何捕捉DataRowChanged每个DataTablein 的事件Dictionary<int, List<DataSet>>

4

2 回答 2

2
    Dictionary<int, List<DataSet>> dict = new Dictionary<int, List<DataSet>>();
    foreach (var d in dict)
    {
        foreach (DataSet ds in d.Value)
        {
            foreach (DataTable dt in ds.Tables)
            {
                dt.RowChanged += new DataRowChangeEventHandler(dt_RowChanged);    
            }
        }
    }
于 2012-05-24T10:50:19.943 回答
1

就像是

foreach(var kvp in dictionary){
kvp.Value.ForEach(dataset=>dataset.Tables.Cast<DataTable>().ToList().ForEach(table=>table.RowChanged+=yourhandler));
}

或更长的版本:

foreach(var kvp in dictionary)
{
    foreach(var dataset in kvp.Value)
    {
        foreach(var table in dataset.Tables)
        {  
            table.RowChanged+=yourhandler;
        }
    }
}
于 2012-05-24T10:47:35.310 回答