title: DataGridViewComboBoxColumn DataSource?
body: <p>I'm trying to get something set up in a <code>DataGridView</code>. It seems like this should be pretty straightforward but I'm having trouble. I want to display three columns:</p>
  
  <ul>
  <li>CodeID</li>
  <li>CodeName</li>
  <li>ComboBox with DisplayMember of TypeName, ValueMember of TypeID</li>
  </ul>
  
  <p>I want to be able to select from all possible values of <code>TypeName</code>. Here's my dilemma:</p>
  
  <p>If I load all of this into one <code>DataTable</code> and set the <code>DataGridView</code> as the <code>DataSource</code>, I can display the existing <code>TypeName</code> for that record, but the combo box will not include any other values. If I set the <code>DataSource</code> for the <code>DataGridViewComboBoxColumn</code> to a separate <code>DataTable</code> that includes all possible <code>TypeNames</code>, the existing value is not displayed.</p>
  
  <p><code>DataGridView</code> is really annoying to work with so either a solution for this or a viable alternative would be appreciated.</p>
  
  <p>Edit: it appears the issue is caused by my wanting to have a separate item for <code>DisplayMember</code> and <code>ValueMember</code>. The following works, if I don't worry about setting the <code>ID</code> as the <code>ValueMember</code>:</p>
  
  <pre><code>var typeColumn = new DataGridViewComboBoxColumn
  {
      DataSource = typeList,
      DisplayMember = "Type",
      ValueMember = "Type",
      DataPropertyName = "Type"
  }
  </code></pre>
  
  <p>If I do the following, the right types are selected, but I can't change the selection in the combo box:</p>
  
  <pre><code>var typeColumn = new DataGridViewComboBoxColumn
  {
      DataSource = typeList,
      DisplayMember = "Type",
      ValueMember = "TypeID",
      DataPropertyName = "TypeID"
  }
  </code></pre>
  
  <p>If I use the following I get a <code>FormatException</code> error as it's trying to populate:</p>
  
  <pre><code>var typeColumn = new DataGridViewComboBoxColumn
  {
      DataSource = typeList,
      DisplayMember = "Type",
      ValueMember = "TypeID",
      DataPropertyName = "Type"
  }
  </code></pre>
  
  <p><strong>edit</strong>: <code>typeList</code> is a simple <code>DataTable</code> populated by the following:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT DISTINCT IT.InsuranceTypeID, IT.[Type]
  FROM InsuranceType IT
  WHERE IT.ClientID = @ClientID
  ORDER BY [Type]
  </code></pre>