title: What is required to refresh bound data displayed on winform?
body: <p>Scenario:</p>
  
  <ul>
  <li>A child form which is made visible via a button.</li>
  <li>A delegate is created to run certain code when this child is closed.</li>
  <li>The child form is used to edit the underlying data</li>
  <li>When the child form is closed the latest version of the data should be displayed on any bound controls on the parent form.</li>
  </ul>
  
  <p>Question - </p>
  
  <p>Here is the relevant code attempt:</p>
  
  <pre><code>public partial class uxRevisionHelperForm : Form
  {
  
      public SqlCeConnection conn = new SqlCeConnection(ConfigurationManager.ConnectionStrings["WindFormAppRevisionHelper.Properties.Settings.DefinitionsDBConnectionString"].ConnectionString);
      BindingSource definitionsBindingSource = new BindingSource();
  
      public uxRevisionHelperForm()
      {
          InitializeComponent();
          uxDescriptionTextBox.AutoSize = true;
          refreshBindingSource();
          assignControlsToSource();
      }
  
        //&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;ALL OF THE FOLLOWING METHOD IS CALLED BY THE DELEGATE WHEN THE CHILD IS CLOSED
      public void refreshBindingSource()
      {            
  
          SqlCeDataAdapter da = new SqlCeDataAdapter(new SqlCeCommand("Select * From tb_RevisionDefinitions",conn));
          DataSet ds = new DataSet("Helper");
          ds.Tables.Add("DefinitionsTable");
          da.Fill(ds.Tables["DefinitionsTable"]);
  
          // Assign the BindingSource.
          definitionsBindingSource.DataSource = ds.Tables["DefinitionsTable"];
          uxBindingNavigator.BindingSource = this.definitionsBindingSource;
  
      }
      void assignControlsToSource() 
      {
          uxDescriptionTextBox.DataBindings.Add(new Binding("Text", definitionsBindingSource, "Description", true));
          uxWordPhraseTextBox.DataBindings.Add(new Binding("Text", definitionsBindingSource, "WordPhrase", true));
          uxReferenceTextBox.DataBindings.Add(new Binding("Text", definitionsBindingSource, "Reference", true));
      }
  
      private void uxUpdateDataButton_Click(object sender, EventArgs e)   
      {
          uxRevisionHelperGroupBox.Enabled = false;
          uxBindingNavigator.Hide();
          uxFormDatabase myNewDisplay = new uxFormDatabase();
          myNewDisplay.FormClosed += delegate { activateGroupBorder(); };
          myNewDisplay.Show();    
      }
  
      public void activateGroupBorder() 
      {
          uxRevisionHelperGroupBox.Enabled = true;
          uxBindingNavigator.Show();
          refreshBindingSource();    //&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;DELEGATE CALLS THIS METHOD
      }
  
  }
  </code></pre>
  
  <p>The above seems to work but do I really have to run all the code in the method <code>refreshBindingSource</code> to make sure the info displayed on the parent form is up-to-date ?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've followed Amiram's advice and passed in my BindingSource so as not to have to repeat code already in place for the parent form. I've copied in some boiler plate code the method <code>saveToolStripButton_Click</code>; ... really don't know what is going on in that small routine - will those two lines will suffice for saving info back to the database?</p>
  
  <pre><code>public partial class uxFormDatabase : Form
  {
  
      BindingSource rawtableBindingSource = null;
  
      public uxFormDatabase(BindingSource myPassedSource) 
      {
          InitializeComponent();
          rawtableBindingSource = myPassedSource;
  
          uxDGVtable.AutoSize = true;
          uxDGVtable.SizeChanged += new EventHandler(uxDGVtable_change);
          dataToDGV();
      }
      public void uxDGVtable_change(object sender, EventArgs e)
      {
          if (uxDGVtable.Width &lt; 1158)
          {
              this.Width = uxDGVtable.Width;
          }
      }
  
      public void dataToDGV()
      {
          uxrawdataBindingNavigator.BindingSource = this.rawtableBindingSource;
          uxDGVtable.DataSource = this.rawtableBindingSource;
      }
  
      private void saveToolStripButton_Click(object sender, EventArgs e)
      {
          Validate();
          rawtableBindingSource.EndEdit();
      }
  
  }
  </code></pre>