title: DataBinding a Combobox to custom object fails to show data
body: <p>I'm having a problem with databinding an object to a combobox in VB.NET (VS2008/.NET 3.5). Please take a look at this simplified version of my code:</p>
  
  <pre><code>Friend Class clDocument
      Private _items as New List(Of clDocumentItems)
  
      &lt;System.ComponentModel.DisplayName("Items")&gt; _
      &lt;System.ComponentModel.Bindable(True)&gt; _
      Public Property Items() As List(Of clDocumentItems)
          Get
              Return _items
          End Get
          Set(ByVal value As List(Of clDocumentItems))
              _items = value
              RaiseEvent ItemsChanged(Me, New EventArgs)
          End Set
      End Property
  
      Public Event ItemsChanged As EventHandler
  End Class
  Friend Class clDocumentItems
      Private _uid as String = ""
      Private _docnumber as String = ""
  
      &lt;System.ComponentModel.DisplayName("UID")&gt; _
      &lt;System.ComponentModel.Bindable(True)&gt; _
      Public Property UID() As String
          Get
              Return _uid
          End Get
          Set(ByVal value As String)
              _uid = value
              RaiseEvent UIDChanged(Me, New EventArgs)
          End Set
      End Property
      &lt;System.ComponentModel.DisplayName("Document")&gt; _
      &lt;System.ComponentModel.Bindable(True)&gt; _
      Public Property DocNumber() As String
          Get
              Return _docnumber
          End Get
          Set(ByVal value As String)
              _docnumber = value
              RaiseEvent DocNumberChanged(Me, New EventArgs)
          End Set
      End Property
  
      Public Event UIDChanged As EventHandler
      Public Event DocNumberChanged As EventHandler
  End Class
  </code></pre>
  
  <p>Somewhere else, we got this code:</p>
  
  <pre><code>Private Sub cmd_go_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_go.Click
          'Try to load the object with data, this works well
          Dim _document as New clDocument
          _document.Load(somevalue)
  
          cmb_docs.DataSource = Nothing
          cmb_docs.Items.Clear()
          If _document.UID = "" Then Exit Sub 'Object wasn't loaded so get out
  
          'Create the binding.     
          cmb_docs.ValueMember = "UID"
          cmb_docs.DisplayMember = "DocNumber"
          cmb_docs.DataSource = _document.Items
  End Sub
  </code></pre>
  
  <p>Now, the problem is that the ComboBox is populated with as many items as there are objects in _document.Items, but it doesn't passes real data -The combobox is filled with "Namespace.clDocumentItems" strings. Please note that similar code works perfectly when bound to regular class properties (String, integer, etc).</p>
  
  <p>Now, I can guess by using the debugger's reflection that it is because the Datsource is receiving a List of objects instead of fields, but then again I don't know how to avoid that without having to create another Array or List with just those values and passing THAT to the Datasource property...</p>
  
  <p>I explored the site for something similar, the only thing that came close was <a href="https://stackoverflow.com/questions/2043397/databinding-a-list-in-an-object-to-a-combobox-in-vb-net">this question</a> that went unanswered 3 years ago, so I hope to have better luck today ;)</p>
  
  <p>Thanks for your time!</p>
  
  <p>EDIT: Below I add the code I used for databinding to a DataGridView, as requested in the comments.</p>
  
  <pre><code>    Private WithEvents _bs as New BindingSource
  
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
          DataGridView1.AutoGenerateColumns = False
          Dim column As DataGridViewColumn = New DataGridViewTextBoxColumn()
          column.DataPropertyName = "Document"
          column.Name = "colDoc"
          DataGridView1.Columns.Add(column)
  
          _bs.DataSource = _document.Items 
          Me.DataGridView1.DataSource = _bs
      End Sub
  </code></pre>