Evento DataRepeater.AllowUserToAddItemsChanged

Ocorre quando o AllowUserToAddItems as alterações de propriedade.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (em Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintaxe

'Declaração
Public Event AllowUserToAddItemsChanged As EventHandler
public event EventHandler AllowUserToAddItemsChanged
public:
 event EventHandler^ AllowUserToAddItemsChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
member AllowUserToAddItemsChanged : IEvent<EventHandler,
    EventArgs>
JScript não oferece suporte a eventos.

Comentários

Quando o AllowUserToAddItems propriedade estiver definida como True, os usuários podem adicionar uma nova linha clicando o BindingNavigatorAddNewItemToolStripButton na BindingNavigator controle, ou pressionando CTRL + N quando um DataRepeaterItem tem foco.

Quando o AllowUserToAddItems propriedade estiver definida como False, a função do teclado CTRL + N for desabilitada, mas o BindingNavigatorAddNewItemToolStripButton ainda está ativado.Se você quiser impedir que usuários adicionem linhas, também deve desabilitar ou remover o BindingNavigatorAddNewItemToolStripButton sobre o BindingNavigator controle.

Para obter mais informações sobre como manipular eventos, consulte Consumindo eventos.

Exemplos

O exemplo de código a seguir demonstra como desabilitar o Add quando o AllowUserToAddItems propriedade estiver definida como False.Ele presume que você tenha um formulário que contém um DataRepeater controle denominado DataRepeater1 e um BindingNavigator controle denominado ProductsBindingSource.

Private Sub DataRepeater1_AllowUserToAddItemsChanged(
    ) Handles DataRepeater1.AllowUserToAddItemsChanged

    ' If this event occurs during form initialization, exit.
    If Me.IsHandleCreated = False Then Exit Sub
    ' If AllowUserToAddItems is False.
    If DataRepeater1.AllowUserToAddItems = False Then
        ' Disable the Add button.
        BindingNavigatorAddNewItem.Enabled = False
        ' Disable the BindingSource property.
        ProductsBindingSource.AllowNew = False
    Else
        ' Otherwise, enable the Add button.
        BindingNavigatorAddNewItem.Enabled = True
    End If
End Sub
private void dataRepeater1_AllowUserToAddItemsChanged(object sender, System.EventArgs e)
{
    // If this event occurs during form initialization, exit.
    if (this.IsHandleCreated == false) { return; }
    // If AllowUserToAddItems is False.
    if (dataRepeater1.AllowUserToAddItems == false)
    // Disable the Add button.
    {
        bindingNavigatorAddNewItem.Enabled = false;
        // Disable the BindingSource property.
        productsBindingSource.AllowNew = false;
    }
    else
    {
        // Otherwise, enable the Add button.
        bindingNavigatorAddNewItem.Enabled = true;
    }
}

Segurança do .NET Framework

Consulte também

Referência

DataRepeater Classe

Namespace Microsoft.VisualBasic.PowerPacks

AllowUserToAddItems

AllowUserToDeleteItems

Outros recursos

Introdução ao controle DataRepeater (Visual Studio)

Como: desativar a adicionar e excluir itens de DataRepeater (Visual Studio)