【问题标题】:Changing the selection of RadioButtons in a GroupBox within a DataRepeater will change the selection of other RadioButtons更改 DataRepeater 内 GroupBox 中 RadioButtons 的选择将更改其他 RadioButtons 的选择
【发布时间】:2014-05-19 19:43:22
【问题描述】:

我有一个 DataRepeater,其中有一个标签 (LabelID) 和一个包含 RadioButtons 的 GroupBox。我将标签绑定到 DataTable 中的一列,我想做的是让用户有机会在 DataRepeater 的每个单元格中选择一个单选按钮,然后在进行时我希望读取用户对每个单元格的选择.问题在于,当用户开始选择单选按钮并向下滚动以选择 DataRepeater 中其他单元格的单选按钮时,先前的选择会发生变化,甚至用户尚未选择的选择也会被选中。我不知道为什么会这样。

这是我所做的代码:

LabelID.DataBindings.Clear()
LabelID.DataBindings.Add(New Binding("Text", SomeDataTable, "SomeID"))
myDataRepeater.DataSource = SomeDataTable

我在 Visual Studio 拖放框架中添加了包含 RadioButtons 的 GroupBox。

我尝试了以下绑定作为我认为可以解决问题的方法,但它没有。

GroupBoxSelection.DataBindings.Clear()
GroupBoxSelection.DataBindings.Add(New Binding("Tag", SomeDataTable, "SomeID"))

我知道这与上下滚动 DataRepeater 有关。因为我增加了 DataRepeater 的大小以摆脱 ScrollBar,这种奇怪的行为将不再发生。我不能让 DataRepeater 保持那么大,所以我想找到另一个解决方案。

任何帮助将不胜感激?

【问题讨论】:

    标签: vb.net radio-button groupbox datarepeater


    【解决方案1】:

    我不知道DataRepeater 是如何工作的,但如果它重用控件来提高性能,我不会感到惊讶。如果是这样,那么您的控件可能会在移动时保留其值。您可能会尝试创建一个用户控件来包含 RadioButtons 并公开一个您可以绑定的属性。如果一个实例被重用,那么绑定应该像其他控件一样正确更新。

    【讨论】:

    • 我尝试了您的建议,但完全相同的问题仍然存在。 :(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 2021-09-25
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 2013-06-14
    相关资源
    最近更新 更多