DataRepeater.AllowUserToAddItems (Propiedad)
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
'Declaración
Public Property AllowUserToAddItems As Boolean
public bool AllowUserToAddItems { get; set; }
public:
property bool AllowUserToAddItems {
bool get ();
void set (bool value);
}
member AllowUserToAddItems : bool with get, set
function get AllowUserToAddItems () : boolean
function set AllowUserToAddItems (value : boolean)
Valor de propiedad
Tipo: Boolean
Es true si el usuario puede agregar filas; en caso contrario, es false.De manera predeterminada, es true.
Comentarios
When the AllowUserToAddItems property is set to True, users can add a new row by clicking the BindingNavigatorAddNewItem ToolStripButton 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 BindingNavigatorAddNewItem ToolStripButton is still enabled. If you want to prevent users from adding rows, you should also disable or remove the BindingNavigatorAddNewItem ToolStripButton on the BindingNavigator control.
Ejemplos
En el ejemplo de código siguiente se muestra cómo deshabilitar el agregar botón cuando el AllowUserToAddItems propiedad está establecida en False. Se supone que tiene un formulario que contenga un DataRepeater control denominado DataRepeater1 y un BindingNavigator control 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;
}
}
Seguridad de .NET Framework
- 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)