Validation Rule to check a child collection is populatedValidation Rule to check a child collection is populated
Old forum URL: forums.lhotka.net/forums/t/3182.aspx
pfeds posted on Thursday, July 12, 2007
Hi,
Firstly sorry if this is a bit of a "noob" post!?
I need to ensure that a child collection has at least one entry. Is it possible to add this as a validation rule in the parent object?
Thanks.
ajj3085 replied on Thursday, July 12, 2007
Yup. Create the rule as you would suspect, and then you'll need to have the parent listen to the child collections ListChanged event.
renegrin replied on Tuesday, September 11, 2007
How would you have the parent listen to the events?
Marjon1 replied on Tuesday, September 11, 2007
To listen to events you would do the following; note the extra WithEvents as part of the variable declaration:
Private WithEvents _LineItems As ChildList = ChildList.NewList()
Public ReadOnly Property ChildListProperty() As ChildList
Get
Return _ListItems
End Get
Public Sub ListChanged_Method(ByVal sender As Object, ByVal e As System.ComponentModel.ListChangedEventArgs) Handles _LineItems.ListChanged
PropertyHasChanged("ChildListProperty")
End Sub
Copyright (c) Marimer LLC