为什么将我的单选按钮绑定到应用程序设置会在单击时改变其行为?
可能的重复:
使用 ApplicationSettings 存储 WinForms RadioButtons 的 Checked 属性 < /p>
I组框中有三个单选按钮。当它们未绑定到应用程序设置时,它们的行为正常。
将每个选中的属性绑定到应用程序设置后,会发生以下情况:我必须单击未选中的单选按钮两次才能将其选中。第一次单击后,所有三个都被取消选中。
我也尝试只绑定其中两个,但行为是相同的。
有人可以帮忙解决这个问题吗?
谢谢。
Possible Duplicate:
Using ApplicationSettings to store Checked property for WinForms RadioButtons
I have three radiobuttons in a groupbox. When they are not bound to application settings, they behave normally.
After binding each of their checked properties to application settings, the following happens: I have to click an unchecked radiobutton two times to have it checked. After the first click, all three are unchecked.
I also tried binding only two of them, but the behaviour is the same.
Can anyone please help with this?
Thanks.
I also asked on MSDN Visual Basic General Forum.
您可以将以下事件处理程序添加到 GroupBox 中三个 RadioButton(其中 Checked 属性绑定到应用程序设置)中每一个的 Click 事件中:
它可以工作,即使未选中的 RadioButton 需要半秒的时间。点击后检查。
两年前(2008 年)幸存 WinForms 数据绑定 发表在 Turbulent Intelect 博客上(谢谢 ohadsc 提供的链接) :
You can add the following event handler to the Click event of each of the three RadioButtons (of which the Checked properties are bound to Application Settings) in your GroupBox:
It works, even though it takes a half-second for an unckecked RadioButton to be checked after you click it.
The reason for the problem was explained two years ago (in 2008) in section 5 of the Surviving WinForms Databinding post on the Turbulent Intelect blog (Thank you, ohadsc, for the link):