Share via


DataRepeater.CurrentItemIndex Property

 

Gets or sets the current 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 CurrentItemIndex { get; set; }
public:
[BrowsableAttribute(false)]
property int CurrentItemIndex {
    int get();
    void set(int value);
}
[<BrowsableAttribute(false)>]
member CurrentItemIndex : int with get, set
<BrowsableAttribute(False)>
Public Property CurrentItemIndex As Integer

Property Value

Type: System.Int32

The index of the current DataRepeaterItem.

Remarks

Use this property to return or change the index of the CurrentItem in a DataRepeater control. Setting the CurrentItemIndex property scrolls the DataRepeaterItem that has the equivalent index into view.

Note

The DataRepeaterItem will be scrolled fully into view using a minimum scroll strategy. To align the item with the top of the DataRepeater, call the ScrollItemIntoView method, specifying true for the AlignWithTop parameter.

Examples

The following example demonstrates how to use the CurrentItemIndex property to set the focus to an item in a DataRepeater control, depending on the results of a search. It assumes that you have a DataRepeater control named DataRepeater1, a TextBox named SearchTextBox, and a Button named SearchButton, and that the DataRepeater is bound to a data source for the Northwind database Products table.

private void searchButton_Click(System.Object sender, System.EventArgs e)
{
    int foundIndex;
    string searchString;
    searchString = searchTextBox.Text;
    foundIndex = productsBindingSource.Find("ProductID", searchString);
    if (foundIndex > -1)
    {
        dataRepeater1.CurrentItemIndex = foundIndex;
    }
    else
    {
        MessageBox.Show("Item " + searchString + " not found.");
    }
}
Private Sub SearchButton_Click() Handles SearchButton.Click
    Dim foundIndex As Integer
    Dim searchString As String
    searchString = SearchTextBox.Text
    foundIndex = ProductsBindingSource.Find("ProductID", 
       searchString)
    If foundIndex > -1 Then
        DataRepeater1.CurrentItemIndex = foundIndex
    Else
        MsgBox("Item " & searchString & " not found.")
    End If
End Sub

See Also

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

Return to top