There is no documented way, you'll have to use your own editor. But you can derive from the standard editor class. Here is an example of such a hack:
Define the custom editor attribute like this on the collection property:
[Editor(typeof(MyCollectionEditor), typeof(UITypeEditor))]
public List<Child> Children { get; }
With this editor code:
// CollectionEditor needs a reference to System.Design.dll
public class MyCollectionEditor : CollectionEditor
{
public MyCollectionEditor(Type type)
: base(type)
{
}
protected override CollectionForm CreateCollectionForm()
{
CollectionForm form = base.CreateCollectionForm();
var addButton = (ButtonBase)form.Controls.Find("addButton", true).First();
addButton.Click += (sender, e) =>
{
MessageBox.Show("hello world");
};
return form;
}
}
The add button is a simple Winforms button, so you can do anything with it.
CollectionBase
decision: Guidelines for Collections. I've done things with complex collections using a custom UITypeEditor. It would look for an Interface on the Type being created and make a call to the class to do whatever. I am not entirely sure that Prop Grid would use the UITypeEditor but it would be easy to find out. – Brassy