DataRepeater.AllowUserToDeleteItems (Propiedad)
Actualización: noviembre 2007
Obtiene o establece un valor que determina si los usuarios pueden eliminar una fila de 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 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 propiedad
Tipo: System.Boolean
true si el usuario puede eliminar filas; de lo contrario, false. El valor predeterminado es true.
Comentarios
Cuando la propiedad AllowUserToDeleteItems está establecida en True, los usuarios pueden eliminar filas haciendo clic en el botón BindingNavigatorDeleteItemToolStripButton en el control BindingNavigator o presionando SUPRIMIR cuando DataRepeaterItem tiene el foco.
Cuando la propiedad AllowUserToDeleteItems está establecida en False, la función de teclado SUPRIMIR está deshabilitada, pero el botón BindingNavigatorDeleteItemToolStripButton todavía está habilitado. Si desea impedir que los usuarios eliminen filas, debe deshabilitar o quitar también el botón BindingNavigatorDeleteItemToolStripButton en el control BindingNavigator.
Ejemplos
El ejemplo de código siguiente muestra cómo deshabilitar el botón Eliminar ToolStripButton 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.
Private Sub DataRepeater1_AllowUserToDeleteItemsChanged _
(ByVal sender As Object, ByVal e As System.EventArgs) 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(ByVal sender _
As Object, ByVal e As System.EventArgs) 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;
}
}
}
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)