2011-01-17 59 views

答えて

4

これは動作するはずです:

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

Schmelterからのコードは、現在の行を変更しますが、それはUIを更新し、発射する他のデータハンドリングイベントが発生することができますので、これは望ましくない影響が生じる可能性があります。 CurrentItemIndexを変更してDataRepeaterItemsをループする必要はありません。各DataRepeaterItemは、DataRepeater.Controlsコレクション内の単なるControlオブジェクトです。代替案があります(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 
    } 
関連する問題