Share via


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)

Syntax

[BrowsableAttribute(false)]
public int FirstDisplayedItemIndex { get; }
public:
[BrowsableAttribute(false)]
property int FirstDisplayedItemIndex {
    int get();
}
[<BrowsableAttribute(false)>]
member FirstDisplayedItemIndex : int with get
<BrowsableAttribute(False)>
Public ReadOnly Property FirstDisplayedItemIndex As Integer

Property Value

Type: System.Int32

The index of the first displayed DataRepeaterItem.

Remarks

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.

Note

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.

Examples

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;
    }
}
Private Sub SynchButton_Click() Handles SynchButton.Click
    ' If the first displayed item is not the current item.
    If DataRepeater1.FirstDisplayedItemIndex <> 
     DataRepeater1.CurrentItemIndex Then
        ' Make it the current item.
        DataRepeater1.CurrentItemIndex = 
          DataRepeater1.FirstDisplayedItemIndex
    End If
End Sub

See Also

DisplayedItemCount
ScrollItemIntoView
DataRepeater Class
Microsoft.VisualBasic.PowerPacks Namespace
Introduction to the DataRepeater Control (Visual Studio)

Return to top