Share via


DataRepeater.CurrentItemIndexChanged (Evento)

Se produce cuando cambia la propiedad CurrentItemIndex.

Espacio de nombres:  Microsoft.VisualBasic.PowerPacks
Ensamblado:  Microsoft.VisualBasic.PowerPacks.Vs (en Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintaxis

'Declaración
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 no admite eventos.

Comentarios

El CurrentItemIndex cambia cuando el usuario selecciona un nuevo DataRepeaterItem o cuando la CurrentItemIndex se establece en el código.

Establecer el CurrentItemIndex propiedad desplaza el DataRepeaterItem que tiene el índice equivalente en la vista.

Para obtener más información acerca de cómo controlar eventos, vea Controlar y provocar eventos.

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar el CurrentItem propiedad realizar cambios cuando se selecciona un elemento. Se supone que tiene un formulario que contiene un límite DataRepeater denominado DataRepeater1, un límite TextBox denominado UnitsInStockTextBoxy un Label denominado 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;
    }
}

Seguridad de .NET Framework

Vea también

Referencia

DataRepeater Clase

Microsoft.VisualBasic.PowerPacks (Espacio de nombres)

CurrentItemIndex

Otros recursos

Introducción al control DataRepeater (Visual Studio)