title: ComboBox and KeyValuePair List not working correctly
body: <p>I have created a ComboBox on a <a href="http://en.wikipedia.org/wiki/Windows_Forms" rel="nofollow">Windows Forms</a> form. It is Databound to a column in a TableAdapter and the DataSource is a manually created KeyValuePair List. The problem is that when the form is displayed; the ValueMember is displayed in the ComboBox, not the DisplayMember. If you click the drop down, the Key List Values are displayed. When you make a selection, in the OnValidating method, the SelectedItem is -1.</p>
  
  <p>I believe that the ComboBox is setup correctly. What have I done wrong?</p>
  
  <pre><code>this.cboFormat.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.BindingSource, "Format", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged));
  
  InitializeComponent();
  
  List&lt;KeyValuePair&lt;int, string&gt;&gt; loFormat = new List&lt;KeyValuePair&lt;int, string&gt;&gt;();
  loFormat.Add(new KeyValuePair&lt;int, string&gt;(1, "Format 1"));
  loFormat.Add(new KeyValuePair&lt;int, string&gt;(2, "Format 2"));
  loFormat.Add(new KeyValuePair&lt;int, string&gt;(3, "Format 3"));
  
  this.cboFormat.DataSource = new BindingSource(loFormat, null);
  this.cboFormat.DisplayMember = "Value";
  this.cboFormat.ValueMember = "Key";
  </code></pre>
  
  <hr/>
  
  <p>Problem solved:</p>
  
  <p>I found that if the Column in the DataBinding is an int, but the Value from the List is a string, then the problem above resulted. I changed the Databinding to a view that displayed the text from the lookup table the int tied to. The Key of the List would be the int from the lookup table. If that makes any sense.</p>
  
  <pre><code>SELECT DisplayMember FROM LookupTable AS LT INNER JOIN DataTable AS DT ON LT.Id = DT.LookupId.
  </code></pre>
  
  <p>Then the KeyValuePair worked as expected.</p>