Condividi tramite


Evento DataRepeater.CurrentItemIndexChanged

si verifica quando CurrentItemIndex modifiche.

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

CurrentItemIndex modifiche quando l'utente seleziona un nuovo DataRepeaterItem oppure quando CurrentItemIndex è impostato nel codice.

impostare CurrentItemIndex la proprietà scorre DataRepeaterItem ciò ha indice equivalente nella visualizzazione.

per ulteriori informazioni su come gestire gli eventi, vedere Utilizzo degli eventi.

Esempi

Nell'esempio seguente viene illustrato come utilizzare CurrentItem proprietà per apportare modifiche quando viene selezionato un elemento.Si presuppone che si disponga di un form contenente un limite DataRepeater denominato DataRepeater1, un limite TextBox denominato UnitsInStockTextBoxe 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)