title: Databinding combobox column to object (or null) in DGV
body: <p>I've done something similar to this in the past and it worked well (except one slightly dirty hack).</p>
  
  <p>I have an object, Machine, that references other objects, like Building, Level, etc. I'm databinding this in a DGV. I have the object lookup columns set up as a <code>DataGridViewComboBoxColumn</code>. I had to do the "Self" property hack as mentioned in a few other posts in order to get the ComboBox to return the object itself instead of an ID or something.</p>
  
  <pre><code>BuildingColumn.DataSource = buildings ' Loaded in from DB
  BuildingColumn.DataPropertyName = "Building" ' Machine.Building
  BuildingColumn.DisplayMember = "Abbreviation" ' Abbreviation of building
  BuildingColumn.ValueMember = "Self" ' A property on the Building object that returns itself
  </code></pre>
  
  <p>I'd like to get rid of the "Self" if possible, but that's really a secondary issue.</p>
  
  <p>The primary problem is that I get DGV Data Errors on the rows where the Machine.Building = Nothing. How do I avoid this? It might also be related that I would like to add an empty option into the ComboBox so the user can empty out the building if they need to. I thought that adding an empty value to the datasource of the ComboBox would fix both of these issues, but it did not.</p>
  
  <p>Any help would be greatly appreciated :).</p>