Condividi tramite


Evento DataRepeater.CurrentItemIndexChanged

Si verifica quando la proprietà CurrentItemIndex viene modificata.

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

Sintassi

'Dichiarazione
Public Event CurrentItemIndexChanged As EventHandler
public event EventHandler CurrentItemIndexChanged
public:
 event EventHandler^ CurrentItemIndexChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
member CurrentItemIndexChanged : IEvent<EventHandler,
    EventArgs>
JScript non supporta gli eventi.

Note

Il CurrentItemIndex cambia quando l'utente seleziona un nuovo DataRepeaterItem o quando il CurrentItemIndex viene impostato nel codice.

Impostare il CurrentItemIndex proprietà consente di scorrere il DataRepeaterItem con l'indice equivalente nella visualizzazione.

Per ulteriori informazioni su come gestire gli eventi, vedere Gestione e generazione di eventi.

Esempi

Nell'esempio seguente viene illustrato come utilizzare il CurrentItem proprietà per apportare modifiche quando viene selezionato un elemento. Si presuppone che si disponga di un modulo che contiene un limite DataRepeater denominato DataRepeater1, un limite TextBox denominato UnitsInStockTextBoxe un Label denominato LowStockWarningLabel.

Private Sub DataRepeater1_CurrentItemIndexChanged(
  ) Handles DataRepeater1.CurrentItemIndexChanged

    ' Exit if the control is first loading. 
    If DataRepeater1.CurrentItem Is Nothing Then Exit Sub 
    ' Check for zero or negative quantity. 
    If CDbl(
        DataRepeater1.CurrentItem.Controls("UnitsInStockTextBox").Text
       ) < 1 Then 
        ' Display a the warning label on the form. 
        Me.LowStockWarningLabel.Visible = True 
    Else 
        Me.LowStockWarningLabel.Visible = False 
    End If 
End Sub
private void dataRepeater1_CurrentItemIndexChanged(object sender, System.EventArgs e)
{
    // Exit if the control is first loading. 
    if (dataRepeater1.CurrentItem == null) { return; }
    // Check for zero quantity. 
    if (dataRepeater1.CurrentItem.Controls["unitsInStockTextBox"].Text == "0") 
    // Display a the warning label on the form.
    {
        this.lowStockWarningLabel.Visible = true;
    }
    else
    {
        this.lowStockWarningLabel.Visible = false;
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

DataRepeater Classe

Spazio dei nomi Microsoft.VisualBasic.PowerPacks

CurrentItemIndex

Altre risorse

Introduzione al controllo DataRepeater (Visual Studio)