题
当我们运行循环并浏览列表 /组合框中的项目时,有什么方法可以通过代码通过代码移动?谢谢Furqan
解决方案
这应该有效:
For i As Integer = 0 To Me.DataRepeater1.ItemCount -1
Me.DataRepeater1.CurrentItemIndex = i
Dim item As DataRepeaterItem = Me.DataRepeater1.CurrentItem
Next
其他提示
Schmelter的代码更改了当前行,但这可能会产生不希望的效果,因为它可以更新UI并导致其他数据处理事件发射。不必更改CurrentIteMindex以循环循环浏览DatarePeaterItems。每个datarepeaterItem只是datarepeater.controls Collection中的一个控制对象。这是一个替代方案(在C#中):
using Microsoft.VisualBasic.PowerPacks;
foreach ( DataRepeaterItem rowItem in dataRepeater1.Controls )
{
int itemIndex = rowItem.ItemIndex;
// If it's bound, get the underlying data object
object dataItem = BindingSource1.List[itemIndex];
// Add code for each rowItem of the dataItem
// All controls on the DataRepeateItem can be obtained from rowItem.Controls
}
不隶属于 StackOverflow