I have subclassed the CollectionEditor to gain access to the CollectionForm and want to be able to know when the Add or Remove button has been clicked. Here's my subclass:
VB.NET:
Imports System.ComponentModel.Design
Public Class MyCollectionEditor
Inherits CollectionEditor
Public Shared bEditingCollection As Boolean = False
Public Delegate Sub MyFormClosedEventHandler(
ByVal sender As Object,
ByVal e As FormClosedEventArgs)
Public Event MyFormClosed As MyFormClosedEventHandler
Public Delegate Sub MyFormLoadEventHandler(
ByVal sender As Object,
ByVal e As System.EventArgs)
Public Event MyFormLoad As MyFormLoadEventHandler
Public Sub New(ByVal type As Type)
MyBase.New(type)
End Sub
Protected Overrides Function CreateCollectionForm() As CollectionForm
Dim collectionForm As CollectionForm = MyBase.CreateCollectionForm
AddHandler collectionForm.FormClosed, AddressOf Me.collection_FormClosed
AddHandler collectionForm.Load, AddressOf Me.collection_FormLoad
Return collectionForm
End Function
Private Sub collection_FormLoad(ByVal sender As Object, ByVal e As System.EventArgs)
bEditingCollection = True
End Sub
Private Sub collection_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs)
bEditingCollection = False
End Sub
End Class