title: Winforms Data Binding to Custom Class
body: <p>I am trying to bind some Winform objects to a custom class, more specifically an instance of my custom class which I have added to the Form in the code.  C#, .NET 2010 Express.</p>
  
  <p>For example, here is a fragment of the class, and the UserInfoForm</p>
  
  <pre><code>public class UserInfo
  {
      [XmlAttribute]
      public string name = "DefaultName";
  
      [XmlAttribute]
      public bool showTutorial = true;
  
      [XmlAttribute]
      public enum onCloseEvent = LastWindowClosedEvent.Exit;
  }
  
  public enum LastWindowClosedEvent
  {
      MainMenu, 
      Exit, 
      RunInBackground
  }
  
  
  public partial class Form1 : Form
  {
      UserInfo userToBind = new UserInfo();
  
      TextBox TB_userName = new TextBox();
      CheckBox CB_showTutorial = new CheckBox();
      ComboBox DDB_onCloseEvent = new ComboBox();
  
      public Form1()
      {
          InitializeComponent();
      }
  }
  </code></pre>
  
  <p>Now, I would like to bind the values of these form controls to their respective value in userToBind, but have had no luck.  All the tutorials I can find are either way out of date (2002), or about binding controls to a dataset, or other type of database.</p>
  
  <p>I am obviously overlooking something, but I haven't figured out what.</p>
  
  <p>Thank you very much for any info you can share.</p>
  
  <p>More info: UserInfo is designed to be XML-friendly so it can be saved as a user profile.  UserInfo will contain other custom XML classes, all nested under the UserInfo, and many controls will only need to access these child classes.</p>