Datarepeaterのアイテムを移動します
-
12-10-2019 - |
質問
Loopを実行してリスト /コンボボックスのアイテムを移動するとき、DatarePeaterのアイテムをコードを介して移動する方法はありますか? 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コレクションの制御オブジェクトにすぎません。これが代替案です(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