Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定
Dim cb As CheckBox = New CheckBox AddHandler cb, AddressOf cb_CheckChanged cb.Checked = True
...除了禁用控件之外,如何防止分配给 Checked 引发 CheckChanged 事件?我在 MFC 中长大,只有在 USER 更改控件的状态时才会引发事件。软软在想什么?真的无法区分来自用户的事件和来自我自己的赋值语句的事件吗? 哎呀!
无论导致事件的原因如何,引发事件都是完全有效的,因为CheckChanged事件只会告诉您Checked属性何时发生变化。
CheckChanged
Checked
如果您试图避免无限循环,则必须尝试添加条件:
If Not cb.Checked Then cb.Checked = True End If