Zdarzenie DataRepeater.CurrentItemIndexChanged
Występuje, gdy CurrentItemIndex zmian.
Przestrzeń nazw: Microsoft.VisualBasic.PowerPacks
Zestaw: Microsoft.VisualBasic.PowerPacks.Vs (w Microsoft.VisualBasic.PowerPacks.Vs.dll)
Składnia
'Deklaracja
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>
Język JScript nie obsługuje zdarzeń.
Uwagi
CurrentItemIndex Zmienia się, gdy użytkownik wybierze nowy DataRepeaterItem lub gdy CurrentItemIndex w kodzie.
Ustawienie CurrentItemIndex przewijania reszty właściwości DataRepeaterItem ma równoważne indeksu w widoku.
Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i wywoływanie zdarzeń.
Przykłady
Poniższy przykład przedstawia sposób użycia CurrentItem właściwość do wprowadzania zmian, jeśli element jest wybrany.Przyjęto założenie, że formularz zawierający powiązanej DataRepeater o nazwie DataRepeater1, powiązanej TextBox o nazwie UnitsInStockTextBoxi Label o nazwie 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;
}
}
Zabezpieczenia programu .NET Framework
- Pełne zaufanie do bezpośredniego wywołującego. Tego elementu członkowskiego nie można używać w kodzie częściowo zaufanym. Aby uzyskać więcej informacji, zobacz Używanie bibliotek pochodzących z częściowo zaufanego kodu.
Zobacz też
Informacje
Przestrzeń nazw Microsoft.VisualBasic.PowerPacks