title: Trying to grab information from a Data Table in Form 2 and set Textboxes in Form 1 using C#
body: <p>I have two forms (Form 1 and Form 2), I am successful in passing a data table from Form 1 to Form 2 by filling a data grid view in a dialog box. I also have an event handler to capture double click events on a selected row. When the event occurs I want to set textboxes in form 1 from the click event in form 2. No matter what I try I can not seem to show the text inside the textboxes. Below is my code:</p>
  
  <pre><code>    //Code begins here
      //....Function to fill data table from form 1 and pass to form 2
      private void buttonNewEntryLookUp_Click(object sender, EventArgs e)
      {
  
          try
          {
              cs.Open();
              da.SelectCommand = new SqlCommand("Select ctx_customername AS Customer, ctx_contactname AS Contact, ctx_custaddress1 AS Address, ctx_custcity AS City, ctx_custstate AS State, nno_custzip AS ZIP, ctx_custemail AS Email FROM Customers WHERE nno_custphone = '" + maskedTextBoxNewLogTel.Text + "'", cs);
              dt.Clear();
              da.Fill(dt);
          }
          catch
          {
              MessageBox.Show("Connection to Database could not be established, please close this application and try again. If problem continues please contact server Admin. Thank you.", "AAMP");
              //Display this message if connection could not be made
          }
          cs.Close();//close connection to db
          if (dt.Rows.Count == 0)//if there are no returned results then this must be a new entry into the database
          {
              MessageBox.Show("Phone Number Not Found in Database.", "AAMP");
          }
          else//number was found
          {
              Form2 form2 = new Form2(dt);//create object of form 2 and pass the data table.
              form2.ShowDialog();//show form 2 with data table in the grid view.
  
          }
      }
      public void getContactInfo(string[] contactInfo)
      {
          textBoxNewLogCustomerName.Text = contactInfo[0];
          textBoxNewLogContactName.Text = contactInfo[1];
          textBoxNewLogAddress.Text = contactInfo[2];
          textBoxNewLogCity.Text = contactInfo[3];
          textBoxNewLogState.Text = contactInfo[4];
          textBoxNewLogZIP.Text = contactInfo[5];
          textBoxNewLogEmail.Text = contactInfo[6];
      }
  
      //code for form 2
      public partial class Form2 : Form
  {  
      /*Globals for Form 2*/
      DataTable g_dt;
      public Form2(DataTable dt)
      {
          InitializeComponent();
          dataGridViewLookUp.DataSource = dt;
          g_dt = dt;
      }
  
      private void dataGridViewLookUp_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
      {
          Form1 form1 = new Form1();
          string[] contactInfo = new string[7];
          contactInfo[0] = Convert.ToString(g_dt.Rows[e.RowIndex]["Customer"]);
          contactInfo[1] = Convert.ToString(g_dt.Rows[e.RowIndex]["Contact"]);
          contactInfo[2] = Convert.ToString(g_dt.Rows[e.RowIndex]["Address"]);
          contactInfo[3] = Convert.ToString(g_dt.Rows[e.RowIndex]["City"]);
          contactInfo[4] = Convert.ToString(g_dt.Rows[e.RowIndex]["State"]);
          contactInfo[5] = Convert.ToString(g_dt.Rows[e.RowIndex]["ZIP"]);
          contactInfo[6] = Convert.ToString(g_dt.Rows[e.RowIndex]["Email"]);
          form1.getContactInfo(contactInfo);//return the row number being clicked.
          this.Close();
  
      }
  }
  </code></pre>
  
  <p>I am successful in passing the data table to form 2 and capturing the correct information to fill the string array but when I pass the string array back by calling the getContactInfo function I can not seem to set my textboxes with the data. Can someone please, please help!</p>
  
  <p>Thanks. </p>