title: To obtain the value in a combo box from the database in c#
body: <p>I have a form1 where the location ID and and the location name are the inputs and displayed. </p>
  
  <p>Now at the same time I have a combobox and a textbox in another form</p>
  
  <p>Now my question is: while we insert a new location in the form1 and insert it in the datagridview, I want the same to be inserted in the  combo box and textbox respectively. </p>
  
  <p>I used the code </p>
  
  <pre><code>dataGridView1.Rows[1].Cells[1].Value.ToString()
  </code></pre>
  
  <p>but it works only for the row one and column 1.</p>
  
  <p>private void gv_Location_CellContentClick(object sender, DataGridViewCellEventArgs e)</p>
  
  <pre><code>    {
  
  
          int i = gv_Location.SelectedCells[0].RowIndex;
  
  
          label1.Text = gv_Location.Rows[i].Cells[0].Value.ToString();
  
  
          label3.Text = gv_Location.Rows[i].Cells[1].Value.ToString();
  
      }
  </code></pre>
  
  <p>now i have the values in the corresponding labels.and i want to insert these two values i.e locationID in a combo box and location name in a textbox which is located in another form</p>