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

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

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 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
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;
    }
}

.NET Framework Security

See Also

Reference

DataRepeater Class

Microsoft.VisualBasic.PowerPacks Namespace

DisplayedItemCount

ScrollItemIntoView

Other Resources

Introduction to the DataRepeater Control (Visual Studio)