Combo Box DisplayMember Refer to Nested Property?

PeterWellington

Newcomer
Joined
Mar 10, 2006
Messages
1
(Abridged code for example purposes)

Class ABC
Public Property XYZObject() As XYZ
End Class

Class XYZ
Property SomeValue As String
End Class

---

I have a combo box where I'm setting the DataSource to an array of ABC objects. I'd like to use the SomeValue property of the XYZObject property of the ABC objects as the DisplayMember of the combo box. When I try to do this (combobox.DisplayMember = "XYZObject.SomeValue"), it doesn't recognize it as being a valid property (combo box instead shows ABC.ToString(), which happens according to the documentation when the property can't be resolved)

Is what I'm trying to do possible or can I only reference properties that directly belong to ABC objects?
 
You cannot use a sub item as the DisplayMember, add another property to ABC that returns XYZObject.SomeProperty(), and use that as the DisplayMember, that should circumvent the problem.
 
Back
Top