Evento DataRepeater.AllowUserToDeleteItemsChanged

Ocorre quando o AllowUserToDeleteItems 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 AllowUserToDeleteItemsChanged As EventHandler
public event EventHandler AllowUserToDeleteItemsChanged
public:
 event EventHandler^ AllowUserToDeleteItemsChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
member AllowUserToDeleteItemsChanged : IEvent<EventHandler,
    EventArgs>
JScript não oferece suporte a eventos.

Comentários

Quando o AllowUserToDeleteItems propriedade estiver definida como True, o usuário pode excluir uma linha clicando o BindingNavigatorDeleteItemToolStripButton na BindingNavigator controle, ou pressionando exclusão quando um DataRepeaterItem tem foco.

Quando o AllowUserToDeleteItems propriedade estiver definida como False, a função do teclado de exclusão for desabilitada, mas o BindingNavigatorDeleteItemToolStripButton ainda está ativado.Se você quiser impedir que o usuário excluir linhas, você também deve desabilitar ou remover o BindingNavigatorDeleteItemToolStripButton 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 BindingNavigatorDeleteItemToolStripButton 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.

Private Sub DataRepeater1_AllowUserToDeleteItemsChanged(
    ) Handles DataRepeater1.AllowUserToDeleteItemsChanged

    ' If this event occurs during form initialization, exit.
    If Me.IsHandleCreated = False Then Exit Sub
    ' If AllowUserToDeleteItems is False.
    If DataRepeater1.AllowUserToDeleteItems = False Then
        ' Disable the Delete button.
        BindingNavigatorDeleteItem.Enabled = False
    Else
        ' Otherwise, enable the Delete button.
        BindingNavigatorDeleteItem.Enabled = True
    End If
End Sub
Private Sub BindingNavigatorDeleteItem_EnabledChanged(
    ) Handles BindingNavigatorDeleteItem.EnabledChanged

    If DataRepeater1.AllowUserToDeleteItems = False Then
        ' The BindingSource resets this property when a 
        ' new record is selected, so override it.
        If BindingNavigatorDeleteItem.Enabled = True Then
            BindingNavigatorDeleteItem.Enabled = False
        End If
    End If
End Sub
private void dataRepeater1_AllowUserToDeleteItemsChanged(object sender, System.EventArgs e)
{
    // If this event occurs during form initialization, exit.
    if (this.IsHandleCreated == false) { return; }
    // If AllowUserToDeleteItems is False.
    if (dataRepeater1.AllowUserToDeleteItems == false)
    // Disable the Delete button.
    {
        bindingNavigatorDeleteItem.Enabled = false;
    }
    else
    {
        // Otherwise, enable the Delete button.
        bindingNavigatorDeleteItem.Enabled = true;
    }
}
private void bindingNavigatorDeleteItem_EnabledChanged(object sender, System.EventArgs e)
{
    if (dataRepeater1.AllowUserToDeleteItems == false)
    // The BindingSource resets this property when a 
    // new record is selected, so override it.
    {
        if (bindingNavigatorDeleteItem.Enabled == true)
        {
            bindingNavigatorDeleteItem.Enabled = false;
        }
    }
}

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)