IDE: Microsoft Visual Studio .NET 2003
Language: Visual Basic .NET 2003
I am using a resource DLL to access an external database via OLE/COM. There is very little documentation aside from what methods are available and I do not have access to the source code. For all intents and purposes, each database item is returned as a DBobject collection.
I have a project wherein I created a ListBox control called Box. In my application, I add items to the list as follows.
Dim List As DBobject = anExistingCollection
Dim Item As DBobject
For Each Item In List
    Box.Items.Add(Item)
Next
From the Object Explorer, I found that there is a property defined in the DLL as follows.
Public Overridable Default Property [Property](Optional ByVal Type As Object = Nothing, Optional ByVal Index As Object = Nothing) As Object
In the code snippet below, I get the selected item and set a label control text value to the name of the DBobject since the "Property" property returns the name of the object by default.
Dim tempDBobject As DBobject
tempDBobject = Box.SelectedItem
Label1.Text = tempDBobject.Property
I set the DisplayMember of the ListBox to "Property" in the design view. When the ListBox is populated, every item is listed as being "System.__ComObject" but the Box.SelectedItems method returns the proper name value to be displayed in Label1.
I even tried the following as the DisplayMember in the design view with identical results. (Note that PropertyGet("Name") is another method to obtain the name value.)
Property
[Property]
"Property"
PropertyGet("Name")
I wrote a sample program with a class of my own design with a property that returned a String as an Object for the DisplayMemeber. It worked flawlessly. Does anyone have any suggestions as to why the proper text isn't being displayed in the ListBox for my real application? Thanks!
Urkle10