title: C# datagridview combobox column datasource from list/dictionary/datatable
body: <p>I've got a datatable and one column is an integer ID foreign key to another database table. </p>
  
  <p>I've got a datagridview and i'd like to use a combobox column to allow user to change value. But instead of using the integers, it would be great to use the names.</p>
  
  <p>I've tried creating a simple struct with public members int ID and string Name; a dictionary and looked into enums (however values not known at compile time) but not got anything to work yet.</p>
  
  <p>I was able to populate the combobox with struct values, but not able to programmatically set the selected item/index; ie, if ID "5" is in the datatable, set the combo box selected item to the struct that has an ID of 5. </p>
  
  <p>So to be clear i'm wanting:</p>
  
  <pre><code>gridview datasource's fk ID's 
  1
  2
  3
  
  Foreign Key table:
  
  ID   Name 
  1    Name 1
  2    Name 2
  3    Name 3
  </code></pre>
  
  <p>Datagridviewcombobox column should be loaded with three items; should display as "Name 1, Name 2, Name 3". Based on the gridview datasource's FK id, the selected item for each should match.</p>