Поделиться через


DataRepeater.ScrollItemIntoView Method (Int32)

Scrolls a specified DataRepeaterItem into view in a DataRepeater control.

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

Syntax

'Declaration
Public Sub ScrollItemIntoView ( _
    index As Integer _
)
public void ScrollItemIntoView(
    int index
)
public:
void ScrollItemIntoView(
    int index
)
member ScrollItemIntoView : 
        index:int -> unit 
public function ScrollItemIntoView(
    index : int
)

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.

The item will be scrolled into view by a minimum scrolling algorithm; it will not necessarily be aligned with the top of the control. To align the item with the top of the control, call the overloaded ScrollItemIntoView method with the alignWithTop parameter set to true.

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
        ' 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)