我怎样才能抓住DataRowChanged
中每个DataTable
的{{1}}个事件?
答案 0 :(得分: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);
}
}
}
答案 1 :(得分: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;
}
}
}