Compartilhar via


Propriedade DataRepeater.AllowUserToAddItems

Obtém ou define um valor que determina se os usuários podem adicionar uma nova linha para 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 AllowUserToAddItems As Boolean

Dim instance As DataRepeater
Dim value As Boolean

value = instance.AllowUserToAddItems

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

Valor de propriedade

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

Comentários

When the AllowUserToAddItems property is set to True, users can add a new row by clicking the BindingNavigatorAddNewItemToolStripButton on the BindingNavigator control, or by pressing CTRL+N when a DataRepeaterItem has focus.

When the AllowUserToAddItems property is set to False, the CTRL+N keyboard function is disabled, but the BindingNavigatorAddNewItemToolStripButton is still enabled.If you want to prevent users from adding rows, you should also disable or remove the BindingNavigatorAddNewItemToolStripButton on the BindingNavigator control.

Exemplos

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

PrivateSub DataRepeater1_AllowUserToAddItemsChanged(ByVal sender _
 AsObject, ByVal e As System.EventArgs) Handles _
 DataRepeater1.AllowUserToAddItemsChanged
    ' If this event occurs during form initialization, exit.IfMe.IsHandleCreated = FalseThenExitSub    ' If AllowUserToAddItems is False.If DataRepeater1.AllowUserToAddItems = FalseThen        ' Disable the Add button.
        BindingNavigatorAddNewItem.Enabled = False        ' Disable the BindingSource property.
        ProductsBindingSource.AllowNew = FalseElse        ' Otherwise, enable the Add button.
        BindingNavigatorAddNewItem.Enabled = TrueEndIfEndSub
privatevoid 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;
    }
}

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)