以编程方式更新时防止 UI 控件上的循环事件链
我有一个 CheckedListBox,其中包含许多可以单独选中或取消选中的项目。
旁边是代表许多相反项的超集的复选框。这些是三态,对应于其项目的哪些部分被相反地选择。
CheckedListBox 和各个 CheckBox 都订阅检查类型更改事件,这会导致循环引用和溢出。如何以编程方式禁止其中一个在另一个正在更新时接收更改事件?
I have a CheckedListBox which contains many items which can be checked or unchecked individually.
Next to this are CheckBoxes representing supersets of the many items opposite. These are tri-state corresponding to what portion of their items are selected opposite.
Both the CheckedListBox and individual CheckBoxes subscribe to check changed type events which is causing a circular reference and overflow. How can I disable one from receiving change events when the other is updating it, programmatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好在对方更新时禁用对方的事件处理程序。
其中 BoxHandler 至少是:
类似于 WinForms:暂时禁用事件handler,但令人惊讶的是,它没有得到答案(可能太抽象了?)。
It works best to disable each others' event handlers as the other is updating.
where BoxHandler is, at a minimum:
Similar to WinForms: temporarily disable an event handler, but amazingly that didn't get awarded an answer, (prolly too abstract?).