Imports System
Imports System.Collections.Generic
Imports System.ComponentModel

Public Class RemovableBindingList(Of T)
    Inherits BindingList(Of T)
    Public Event RemovingItem As EventHandler(Of RemovingItemEventArgs)

    Protected Overrides Sub RemoveItem(ByVal index As Integer)
        ' load up the item to be removed to args and fire event if assigned
        Dim args As RemovingItemEventArgs = Nothing
        If RemovingItemEvent IsNot Nothing Then
            args = New RemovingItemEventArgs(False, Me(index))
            Dim removingItem As EventHandler(Of RemovingItemEventArgs) = _
      RemovingItemEvent
            If RemovingItemEvent IsNot Nothing Then
                RemovingItemEvent(Me, args)
            End If
        End If

        If (Not args.Cancel) Then
            MyBase.RemoveItem(index)
        End If
    End Sub

#Region "constructors"

    Public Sub New(ByVal list As IList(Of T))
        MyBase.New(list)
    End Sub

    Public Sub New()
        MyBase.New()
    End Sub

#End Region
End Class
