Compartilhar via


Propriedade DataRepeater.AllowUserToDeleteItems

Obtém ou define um valor que determina se os usuários podem excluir uma linha de um DataRepeater em time de execução.

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

Sintaxe

Public Property AllowUserToDeleteItems As Boolean

Dim instance As DataRepeater
Dim value As Boolean

value = instance.AllowUserToDeleteItems

instance.AllowUserToDeleteItems = value
public bool AllowUserToDeleteItems { get; set; }
public:
property bool AllowUserToDeleteItems {
    bool get ();
    void set (bool value);
}
public function get AllowUserToDeleteItems () : boolean
public function set AllowUserToDeleteItems (value : boolean)

Valor de propriedade

Tipo: System.Boolean
true Se o usuário pode excluir linhas; caso contrário, false. O padrão é true.

Comentários

When the AllowUserToDeleteItems property is set to True, users can delete rows by clicking the BindingNavigatorDeleteItemToolStripButton on the BindingNavigator control, or by pressing DELETE when a DataRepeaterItem has focus.

When the AllowUserToDeleteItems property is set to False, the DELETE keyboard function is disabled, but the BindingNavigatorDeleteItemToolStripButton is still enabled.If you want to prevent users from deleting rows, you should also disable or remove the BindingNavigatorDeleteItemToolStripButton on the BindingNavigator control.

Exemplos

O exemplo de código a seguir demonstra como desabilitar excluir ToolStripButton botão quando o AllowUserToAddItems propriedade é conjunto para False. Ele presume que você tenha um formulário que contém um DataRepeater controle de chamada DataRepeater1 e um BindingNavigator controle.

PrivateSub DataRepeater1_AllowUserToDeleteItemsChanged _
 (ByVal sender AsObject, ByVal e As System.EventArgs) Handles _
  DataRepeater1.AllowUserToDeleteItemsChanged
    ' If this event occurs during form initialization, exit.IfMe.IsHandleCreated = FalseThenExitSub    ' If AllowUserToDeleteItems is False.If DataRepeater1.AllowUserToDeleteItems = FalseThen        ' Disable the Delete button.
        BindingNavigatorDeleteItem.Enabled = FalseElse        ' Otherwise, enable the Delete button.
        BindingNavigatorDeleteItem.Enabled = TrueEndIfEndSubPrivateSub BindingNavigatorDeleteItem_EnabledChanged(ByVal sender _
 AsObject, ByVal e As System.EventArgs) Handles _
 BindingNavigatorDeleteItem.EnabledChanged
    If DataRepeater1.AllowUserToDeleteItems = FalseThen        ' The BindingSource resets this property when a         ' new record is selected, so override it.If BindingNavigatorDeleteItem.Enabled = TrueThen
            BindingNavigatorDeleteItem.Enabled = FalseEndIfEndIfEndSub
privatevoid 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;
    }
}
privatevoid 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;
        }
    }
}

Permissões

Consulte também

Referência

DataRepeater Classe

Membros DataRepeater

Namespace Microsoft.VisualBasic.PowerPacks

Outros recursos

Introdução ao Controlarar de DataRepeater (Visual Studio)

Como: Desativar adicionando e excluindo itens DataRepeater (Visual Studio)