I have created a custom CollectionEditor
but I want to validate my collection when the user clicks the 'OK' button. I've tried the following:
protected override CollectionForm CreateCollectionForm()
{
_form = base.CreateCollectionForm();
_form.FormClosing += _form_FormClosing;
return _form;
}
So that when the user clicks OK it fires the _form_Closing event. This works however when I do this:
private void _form_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = !Validate();
}
And Validate
returns false
(telling the form not to close) all of the existing members of the collection are removed from the UI
. Surely the items of the collection shouldn't disappear from the UI
?
Is there something else I need to call?