title: binding controls inside a user control
body: <p>I have a user control that contains several text boxes bound to a bindingSource.
  I want to drop that user control onto another form and pass the datasource to the control to use.</p>
  
  <p>I have tried making the user control's bindingSource public and setting it to the same bindingSource on the form,</p>
  
  <pre><code>    List&lt;Person&gt; data = MyGetData(); // returns a list of people
      this.formControl.bindingSource.DataSource = data;   // where formControl is my user control containing bound text boxes.
  </code></pre>
  
  <p>inside my user control I have a textbox called textboxFirstName, and a bindingsource called bindingSource</p>
  
  <p>Using the designer, I set bindingSource.DataSource to be Person  where Person is one of my domain classes.</p>
  
  <p>Also using the designer I set   textboxFirstName.DataBindings.Text to "bindingSource - FirstName"  by picking it from the list of Person properties.</p>
  
  <p>There is no error message, but the text box is not displaying the data.</p>
  
  <p>[Update]
  I can get the binding working if I create the following procedure and call it.</p>
  
  <pre><code>    public void SetBinding(BindingSource bs)
      {
          this.bindingSource = bs;
          this.firstNameTextBox.DataBindings.Clear();
          this.firstNameTextBox.DataBindings.Add(new Binding("Text", bs, "firstName"));
      }
  </code></pre>
  
  <p>However I am wondering why setting the binding source alone is not enough.</p>
  
  <p>Note at design time I had set the user control's bindingSource DataSource to People.  This enabled me to pick the text box's DataBindings.Text property from a list.</p>