Reputation: 5469
How can I catch DataRowChanged
event for each DataTable
in Dictionary<int, List<DataSet>>
?
Upvotes: 0
Views: 193
Reputation: 3348
Something like
foreach(var kvp in dictionary){
kvp.Value.ForEach(dataset=>dataset.Tables.Cast<DataTable>().ToList().ForEach(table=>table.RowChanged+=yourhandler));
}
Or longer version:
foreach(var kvp in dictionary)
{
foreach(var dataset in kvp.Value)
{
foreach(var table in dataset.Tables)
{
table.RowChanged+=yourhandler;
}
}
}
Upvotes: 1
Reputation: 223322
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);
}
}
}
Upvotes: 2