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
public void ScrollItemIntoView(
int index,
bool alignWithTop
)
public:
void ScrollItemIntoView(
int index,
bool alignWithTop
)
member ScrollItemIntoView :
index:int *
alignWithTop:bool -> unit
Public Sub ScrollItemIntoView (
index As Integer,
alignWithTop As Boolean
)
Parameters
index
Type: System.Int32The index of the DataRepeaterItem.
alignWithTop
Type: System.Booleantrue to align the top of the DataRepeaterItem with the top of the control; otherwise, false.
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 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);
}
}
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
See Also
CurrentItemIndex
FirstDisplayedItemIndex
ScrollItemIntoView Overload
DataRepeater Class
Microsoft.VisualBasic.PowerPacks Namespace
Introduction to the DataRepeater Control (Visual Studio)
How to: Search Data in a DataRepeater Control (Visual Studio)
Return to top