Prevent deletion of item
Old forum URL: forums.lhotka.net/forums/t/5349.aspx
bgilbert posted on Friday, September 05, 2008
I'd like to prevent deletion of a collection item. The rule needs to consider a combination of a property in the item as well as another property in an object that contains the collection. For example:
Class ParentRoot
Property PropA As Boolean
ReadOnly Property PropB As ChildCol
Class Child
Property Prop1
If Prop1 is a certain value and PropA is a certain value, prevent the child instance from being removed from the collection.
I don't see a way of writing a rule method in the parent because the child's removal wouldn't hit any parent property. I've tried throwing an exception from the RemovingItem event handler in ParentRoot, but I cannot figure out where to handle this exception in the UI's BindingSource or DataGridView.
Any thoughts?Copyright (c) Marimer LLC