我有这样的代码:
private void treeview1_AfterCheck(object sender, TreeViewEventArgs e)
{
// I tried this, but not helped
// treeview1.BeginUpdate();
if (e.Node.Level == 0)
{
foreach (TreeNode item in e.Node.Nodes)
{
item.Checked = e.Node.Checked;
}
}
// this is a method that executes slow enough,
// that I can click multiple times before it ends
RefreshListOfSelectedItems();
// I tried this, but not helped
// treeview1.EndUpdate();
}
基本上 - 这应该将“已检查”状态复制到子节点,但问题是当我足够快地点击复选框时 - 一切都搞砸了,因为(我认为)我的事件处理程序执行得比我可以点击的慢。