title: Databinding to a custom class in C#
body: <p>I have a class like this:</p>
  
  <pre><code>public class Person
  {
      Int32 id;
      Boolean isMarried = false;
      String displayName;
      Detail mainDetail = new Detail();
      Detail partnerDetail = new Detail();
  }
  
  public class Detail
  {
      String firstName;
      String lastName;
      DateTime dob;
      String address;
  }
  </code></pre>
  
  <p>And then a Form which has selected textboxes to show the information in the object. This is to be updated when the selected person is changed.</p>
  
  <p>Now, for simple fields, such as displayName, this is a piece of cake:</p>
  
  <pre><code>txtTitle.DataBindings.Add("Text", selectedPerson, "displayName");
  </code></pre>
  
  <p>but how do I bind another TextBox to the firstName of the mainDetail property?</p>
  
  <p>This attempt:</p>
  
  <pre><code>txtFirstNameMain.DataBindings.Add("Text", selectedPerson.mainDetail, "firstName");
  </code></pre>
  
  <p>returns a runtime error:</p>
  
  <p>"Cannot bind to the property or column firstName on the DataSource.
  Parameter name: dataMember"</p>
  
  <p>Thanks for your help!</p>