Moving datarepeater items

Is there a way to move datarepeater elements through code when we run a loop and move elements in a list / combo box? thanks furcan

+4
source share
2 answers

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 
+4
source

Schmelter's code changes the current line, but this can lead to undesirable effects, as it can update the user interface and lead to other data processing events. No need to change CurrentItemIndex to loop through 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 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 } 
+5
source

Source: https://habr.com/ru/post/1335831/


All Articles