Freigeben über


DataRepeater.AllowUserToDeleteItemsChanged-Ereignis

Tritt ein, wenn sich die AllowUserToDeleteItems-Eigenschaft ändert.

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

Syntax

'Declaration
Public Event AllowUserToDeleteItemsChanged As EventHandler
public event EventHandler AllowUserToDeleteItemsChanged
public:
 event EventHandler^ AllowUserToDeleteItemsChanged {
    void add (EventHandler^ value);
    void remove (EventHandler^ value);
}
member AllowUserToDeleteItemsChanged : IEvent<EventHandler,
    EventArgs>
JScript unterstützt keine Ereignisse.

Hinweise

When the AllowUserToDeleteItems property is set to True, the user can delete a row by clicking the BindingNavigatorDeleteItem ToolStripButton 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 BindingNavigatorDeleteItem ToolStripButton is still enabled. If you want to prevent the user from deleting rows, you should also disable or remove the BindingNavigatorDeleteItem ToolStripButton on the BindingNavigator control.

Weitere Informationen zum Behandeln von Ereignissen finden Sie unter Behandeln und Auslösen von Ereignissen.

Beispiele

The following code example demonstrates how to disable the BindingNavigatorDeleteItem ToolStripButton button when the AllowUserToAddItems property is set to False. Es wird davon ausgegangen, dass Sie ein Formular mit einem DataRepeater -Steuerelement namens DataRepeater1 und ein BindingNavigator Steuerelement.

Private Sub DataRepeater1_AllowUserToDeleteItemsChanged(
    ) 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(
    ) 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;
        }
    }
}

.NET Framework-Sicherheit

Siehe auch

Referenz

DataRepeater Klasse

Microsoft.VisualBasic.PowerPacks-Namespace

AllowUserToAddItems

AllowUserToDeleteItems

Weitere Ressourcen

Einführung in das DataRepeater-Steuerelement (Visual Studio)

Gewusst wie: Deaktivieren des Hinzufügens und Löschens von DataRepeater-Elementen (Visual Studio)