I'm using the the DevExpress XtraGrid to view a list of contacts and I am trying to add a custom unbound field to display a value from a child record but I am having trouble getting the proper value.
Here is how I am setup:
2 BO's. Contacts & ContactPhoneNumbers on the form with the primary being the contacts.
The parent/child relationship is established and I've set the ParentObject on the ContactPhoneNumbersBO to Contacts.
The Contacts ChildAutoFilterOption property is set to MatchCurrentRow
The Contacts BO is attached to the grid via a BusinessBindingSource object.
I'm loading the Contacts BO and also the ContactPhoneNumbers BO using a custom Fill method which retrieves only the "primary" phone number for the contacts so pretty much all contacts and appropriate phone numbers are loaded during the contact's ParentFormLoading event.
What keeps happening is when the grid executes it's CustomUnboundColumnData event, I'm not able to access the child records.
Here is the event code I am using:
Private Sub gvMain_CustomUnboundColumnData(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs) Handles gvMain.CustomUnboundColumnData Select Case e.Column.FieldName
Case gcPhoneNumber.FieldName
Dim oCurrentContact As Database.ContactsBO = CType(bbsContacts.Item(e.ListSourceRowIndex), Database.ContactsBO)
If (oCurrentContact.ChildBusinessObjects.Count > 0) Then
e.Value = CType(oCurrentContact.ChildBusinessObjects(0), Database.ContactPhoneNumbersBO).PhoneNumber
End If
End Select
End Sub
Can you point to what I am doing incorrectly?
TIA