Condividi tramite


Proprietà DataRepeater.CurrentItemIndex

Ottiene o imposta l'oggetto corrente DataRepeaterItem in DataRepeater controllare.

Spazio dei nomi:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintassi

'Dichiarazione
<BrowsableAttribute(False)> _
Public Property CurrentItemIndex As Integer
[BrowsableAttribute(false)]
public int CurrentItemIndex { get; set; }
[BrowsableAttribute(false)]
public:
property int CurrentItemIndex {
    int get ();
    void set (int value);
}
[<BrowsableAttribute(false)>]
member CurrentItemIndex : int with get, set
function get CurrentItemIndex () : int
function set CurrentItemIndex (value : int)

Valore proprietà

Tipo: System.Int32
L'indice corrente DataRepeaterItem.

Note

Utilizzare questa proprietà per restituire o modificare l'indice di CurrentItem in DataRepeater controllare.impostare CurrentItemIndex la proprietà scorre DataRepeaterItem ciò ha indice equivalente nella visualizzazione.

[!NOTA]

DataRepeaterItem verrà spostato completamente nella visualizzazione utilizzando una strategia minima di scorrimento.Per allineare l'elemento con la parte superiore di l DataRepeater, chiamare ScrollItemIntoView metodo, specificando true per AlignWithTop parametro.

Esempi

Nell'esempio seguente viene illustrato come utilizzare CurrentItemIndex proprietà per impostare lo stato attivo su un elemento in un oggetto DataRepeater controllare, in base ai risultati di una ricerca.Si presuppone che l'utente abbia a DataRepeater controllo denominato DataRepeater1, a TextBox denominato SearchTextBoxe Button denominato SearchButtone che DataRepeater è associato a un'origine dati per la tabella Products del database Northwind.

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
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.");
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

DataRepeater Classe

Spazio dei nomi Microsoft.VisualBasic.PowerPacks

CurrentItemIndexChanged

Altre risorse

Introduzione al controllo DataRepeater (Visual Studio)