DataRepeater.FirstDisplayedItemIndex Property


Gets the index of the first currently displayed DataRepeaterItem in a DataRepeater control.

Namespace:   Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

public int FirstDisplayedItemIndex { get; }

Property Value

Type: System.Int32

The index of the first displayed DataRepeaterItem.

Use this property to determine which item or items are currently visible in the DataRepeater control. This will always return the first item (topmost if the LayoutStyle is set to Vertical, leftmost if LayoutStyle is set to Horizontal) even if that item is only partially visible.


The FirstDisplayedItemIndex is not necessarily the same as the CurrentItemIndex. The CurrentItemIndex represents the selection, whereas the FirstDisplayedItemIndex represents the visible items even when the selection is scrolled out of view.

The following code example demonstrates how to make the first displayed item the currently selected item in a DataRepeater control. It assumes that you have a form that contains a DataRepeater control named DataRepeater1 and a Button control named SynchButton.

private void synchButton_Click(System.Object sender, System.EventArgs e)
    // If the first displayed item is not the current item.
    if (dataRepeater1.FirstDisplayedItemIndex != dataRepeater1.CurrentItemIndex)
    // Make it the current item.
        dataRepeater1.CurrentItemIndex = dataRepeater1.FirstDisplayedItemIndex;
Return to top