title: c# datagridview how to pass value using txtbox in other form
body: <ul>
  <li>form1  i got a gui buttons to pick</li>
  <li>form2 is my datagridview</li>
  <li>form3 is where i input the name surname and mi</li>
  <li>my code for form1 is form2.show </li>
  <li>on my form2 is form3.show</li>
  <li>i have a code in form3 that uses a counter to input in datagridView1</li>
  </ul>
  
  <blockquote>
  <pre><code> private void btnAdd_Click(object sender, EventArgs e)
              {
                  int counter = 0;
                  if (dataGridView1.Rows.Count &gt; 1)
                  {
                      while (counter != dataGridView1.Rows.Count - 1)
                      {
                      if (dataGridView1.Rows[counter].Cells[0].Value.ToString() ==txtName.Text)
                      {
                          MessageBox.Show("name already exist");
                          return;
                      }
                      counter++;
                  }
              }
  if (txtName.Text == "")
              {
                  MessageBox.Show("name field should not be empty");
                  return;
              }
  else
              {
                  dataGridView1.Rows.Add(txtName.Text);
              }
  </code></pre>
  </blockquote>
  
  <ul>
  <li>my problem is that form3 dont recognize dataGridView1 how do i get the value of textbox in form3 into datagridview in form2.</li>
  </ul>