DataRepeater.AllowUserToAddItems (Propiedad)
Actualización: noviembre 2007
Obtiene o establece un valor que determina si los usuarios pueden agregar una nueva fila a DataRepeater en tiempo de ejecución.
Espacio de nombres: Microsoft.VisualBasic.PowerPacks
Ensamblado: Microsoft.VisualBasic.PowerPacks.Vs (en Microsoft.VisualBasic.PowerPacks.Vs.dll)
Sintaxis
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 propiedad
Tipo: System.Boolean
true si el usuario puede agregar filas; de lo contrario, false. El valor predeterminado es true.
Comentarios
Cuando la propiedad AllowUserToAddItems está establecida en True, los usuarios pueden agregar una nueva fila haciendo clic en el botón BindingNavigatorAddNewItemToolStripButton en el control BindingNavigator o presionando CTRL+N cuando DataRepeaterItem tiene el foco.
Cuando la propiedad AllowUserToAddItems está establecida en False, la función de teclado CTRL+N está deshabilitada, pero el botón BindingNavigatorAddNewItemToolStripButton todavía está habilitado. Si desea impedir que los usuarios agreguen filas, debe deshabilitar o quitar también el botón BindingNavigatorAddNewItemToolStripButton en el control BindingNavigator.
Ejemplos
El ejemplo de código siguiente muestra cómo deshabilitar el botón Agregar cuando la propiedad AllowUserToAddItems está establecida en False. Se supone que tiene un formulario que contiene un control DataRepeater denominado DataRepeater1 y un control BindingNavigator denominado ProductsBindingSource.
Private Sub DataRepeater1_AllowUserToAddItemsChanged(ByVal sender _
As Object, ByVal e As System.EventArgs) 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;
}
}
Permisos
- Plena confianza para el llamador inmediato. Un código de confianza parcial no puede utilizar este miembro. Para obtener más información, vea Utilizar bibliotecas de código que no es de plena confianza.
Vea también
Referencia
Microsoft.VisualBasic.PowerPacks (Espacio de nombres)
Otros recursos
Introducción al control DataRepeater (Visual Studio)
Cómo: Deshabilitar las operaciones de agregar y eliminar elementos DataRepeater (Visual Studio)