title: Why does setting ComboBox.SelectedValue to null cause a ArgumentNullException?
body: <p>Why does setting the <code>SelectedValue</code> of a <code>ComboBox</code> to <code>null</code> cause an <code>ArgumentNullException</code>?</p>
  
  <p>The Exception only occurs if the ComboBox is actually part of a Form.
  I can set <code>SelectedValue</code> to all kinds of values or types that don't make sense, but I can't set it to <code>null</code>.</p>
  
  <p>It's not that <code>SelectedValue</code> can not be <code>null</code>. In fact, its value <em>is</em> <code>null</code> at the time I'm trying to set it to <code>null</code>.</p>
  
  <p>In my real code, this doesn't happen in the constructor, and I'm not excplicitly setting it to <code>null</code>. The code is using a variable which happens to be <code>null</code>. I can fix it by checking of the variable isn't <code>null</code> before trying to set the <code>SelectedValue</code>. But what I don't understand is <em>why</em> I can't set it to a <code>null</code> value.</p>
  
  <p><strong>Code edit</strong>: DataSource now contains an item where the ValueMembers value is actually <code>null</code></p>
  
  <pre><code>using System.Collections.Generic;
  using System.Windows.Forms;
  
  public class Form1 : Form {
      public Form1() {
          var comboBox1 = new ComboBox();
          Controls.Add(comboBox1);
          comboBox1.ValueMember = "Key";
          comboBox1.DisplayMember = "Value";
          comboBox1.DataSource = new List&lt;Record&gt; {
              new Record {Key = "1", Value = "One"}, 
              new Record {Key = null, Value = "null"}
          };
          comboBox1.SelectedItem = null;          // no problem
          comboBox1.SelectedValue = "";           // no problem
          comboBox1.SelectedValue = new object(); // no problem
          comboBox1.SelectedValue = null;         // ArgumentNullException!!
      }
  }
  
  public class Record {
      public string Key { get; set; }
      public string Value { get; set; }
  }
  </code></pre>