title: Winforms Binding a ComboBox SelectedItem to an Object Property
body: <p>I have two simple classes:</p>
  
  <pre><code>public class Customer
  {
      public String CustomerID { get; set; }
      public String Forename { get; set; }
      public String Surname { get; set; }
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class Order
  {
      public String OrderID { get; set; }
      public Decimal Value { get; set; }
      public Customer OrderedBy { get; set; }
  }
  </code></pre>
  
  <p>I then create a list of Customer objects:</p>
  
  <pre><code>List&lt;Customer&gt; customers = new List&lt;Customer&gt;();
  customers.Add(new Customer() { CustomerID = "1", Forename = "John", Surname = "Smith"});
  customers.Add(new Customer() { CustomerID = "2", Forename = "Jeremy", Surname = "Smith" });
  </code></pre>
  
  <p>And I have a combo box, against which I set the data source to be my list of Customers, and the DisplayMember to be the Forename property of the Customer object:</p>
  
  <pre><code>comboBox1.DisplayMember = "Forename";
  comboBox1.DataSource = customers;
  </code></pre>
  
  <p>And the result is a combo box with two items, "John" and "Jeremy". Up to now I'm not too confused.</p>
  
  <p>What I would like to be able to do though, is set the "OrderedBy" property of an instance of Order, based on the selection from the Combobox - Can complex types be bound to ComboBoxes like this?</p>
  
  <p>I've tried this, but it doesnt seem to be updating the OrderedBy property of the Order instance:</p>
  
  <pre><code>Order myOrder = new Order();
  comboBox1.DataBindings.Add("SelectedItem", myOrder, "OrderedBy");
  </code></pre>
  
  <p>I dont know if what I'm trying to do is possible, or if it is beyond the capabilities of Data Binding in WinForms.</p>
  
  <p>I'd like to avoid having to update my Order object as part of an event handler on the ComboBox, and solely use Data Binding if possible.</p>