DataRepeater.ScrollItemIntoView Method (Int32, Boolean)

Scrolls a specified DataRepeaterItem into view in a DataRepeater control, optionally aligning it with the top of the control.

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

Syntax

'Declaration
Public Sub ScrollItemIntoView ( _
    index As Integer, _
    alignWithTop As Boolean _
)
public void ScrollItemIntoView(
    int index,
    bool alignWithTop
)
public:
void ScrollItemIntoView(
    int index, 
    bool alignWithTop
)
member ScrollItemIntoView : 
        index:int * 
        alignWithTop:bool -> unit
public function ScrollItemIntoView(
    index : int, 
    alignWithTop : boolean
)

Parameters

Exceptions

Exception Condition
ArgumentOutOfRangeException

The value specified for index is less than 0 or greater than ItemCount - 1.

Remarks

Call the ScrollItemIntoView method to display a specific DataRepeaterItem in the visible part of the control. The item will not be selected. To select the item, set the CurrentItemIndex property.

To align the top of the item with the top of the control, set the alignWithTop parameter to true. If alignWithTop is false, the item will be scrolled into view by a minimum scrolling algorithm; it will not necessarily be aligned with the top of the control.

Examples

The following code example demonstrates how to make the first displayed item the currently selected item in a DataRepeater control and align it with the top of the 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
        ' Align it with the top of the control.
        DataRepeater1.ScrollItemIntoView( 
          DataRepeater1.FirstDisplayedItemIndex, True)
    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;
        // Align it with the top of the control.
        dataRepeater1.ScrollItemIntoView(dataRepeater1.FirstDisplayedItemIndex, true);
    }
}

.NET Framework Security

See Also

Reference

DataRepeater Class

ScrollItemIntoView Overload

Microsoft.VisualBasic.PowerPacks Namespace

CurrentItemIndex

FirstDisplayedItemIndex

Other Resources

Introduction to the DataRepeater Control (Visual Studio)

How to: Search Data in a DataRepeater Control (Visual Studio)