title: Why does ValueMember override an empty DisplayMember
body: <p>When I set a <code>DataSource</code> on a control and want to use <code>.ToString()</code> as <code>DisplayMember</code>, I need to set the <code>DisplayMember</code> last or the <code>ValueMember</code> will override it. </p>
  
  <p><a href="https://msdn.microsoft.com/en-us/library/system.windows.forms.listcontrol.displaymember(v=vs.110).aspx" rel="nofollow noreferrer">MSDN on empty string as display member:</a>  </p>
  
  <blockquote>
    <p>The controls that inherit from ListControl can display diverse types of objects. If the specified property does not exist on the object or the value of DisplayMember is an empty string (""), the results of the object's ToString method are displayed instead.</p>
  </blockquote>
  
  <p><strong>Code to reproduce:</strong>  </p>
  
  <p><strong>Class:</strong></p>
  
  <pre><code>class SomeClass
  {
      public string PartA { get; set; }
      public string PartB { get; set; }
      public string WrongPart { get { return "WRONG";  } }
  
      public override string ToString()
      {
          return $"{PartA} - {PartB}";
      }
  }
  </code></pre>
  
  <p><strong>Form:</strong>  </p>
  
  <pre><code>var testObj = new SomeClass() { PartA = "A", PartB = "B" };
  comboBox1.DataSource = new [] { testObj };
  comboBox1.DisplayMember = "";
  comboBox1.ValueMember = "WrongPart";
  
  comboBox2.DataSource = new[] { testObj };
  comboBox2.ValueMember = "WrongPart";
  comboBox2.DisplayMember = "";
  </code></pre>
  
  <p>You can try it by making a new form and adding 2 combobox's.</p>
  
  <p><strong>Result:</strong>  </p>
  
  <p><a href="https://i.stack.imgur.com/7hSyq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7hSyq.png" alt="enter image description here"></a></p>
  
  <p><strong>Conclusion and question:</strong>  </p>
  
  <p>This can be easily fixed by setting them in the correct order however this is prone to errors, it also does not show this behavior if I use an actual property as DisplayMember instead of <code>""</code>/<code>ToString</code>.</p>
  
  <p>I would really like to know why it displays this behavior and if I could possibly set <code>.ToString()</code> explicitly as DisplayMember (for code clarity).</p>