title: datagrid access from another form
body: <p>I have datagridview in form1. How can I access datagridview from form2.</p>
  
  <pre><code>  private void button1_Click(object sender, EventArgs e)
    {
            string sql1 = "insert into Car (plate, color, [year], model) values ('"+tplate.Text+"','"+tcolor.Text+"',"+tyear.Text+",'"+tmodel.Text+"')";            
            string sql2 = "select * from Car";
              try
              {
                  int res = CarDatabase.executeOthers(sql1);
                  if(res &gt;0){
                      DataTable dt = CarDatabase.executeSelect(sql2);
                      mainframe.Dgv.DataSource = dt;                
                      MessageBox.Show("New Car is added");
                  }
              }
              catch (Exception ex)
              {
                  MessageBox.Show(ex.ToString());
              }
    }
  </code></pre>
  
  <p>here mainframe.Dgv is in the first form</p>
  
  <p>but I cannot access like that Form1.dataGridView why :S</p>