문제

Is there any way to move through datarepeater's items through code, as we run loop and move through the items in a list / combo box? Thanks Furqan

도움이 되었습니까?

해결책

This should work:

   For i As Integer = 0 To Me.DataRepeater1.ItemCount -1
       Me.DataRepeater1.CurrentItemIndex = i
       Dim item As DataRepeaterItem = Me.DataRepeater1.CurrentItem
   Next

다른 팁

The code from Schmelter changes the current row, but this might produce undesired effects since it can update the UI and causes other data-handling events to fire. It's not necessary to change the CurrentItemIndex to loop through the DataRepeaterItems. Each DataRepeaterItem is just a Control object in the DataRepeater.Controls collection. Here is an alternative (in 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  
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top