The problem is that anything on Form2 is it's "Property" and your "parent form" should not be able to access it. If Form1 can access controls on Form2, then you can;t make any changes to Form2 in future without considering very carefully what affects that may have on existing code in Form1, Form3, or whatever might be using Form2!
Instead, use properties and / or constructors in Form2 to pass the information and let it deal with displaying what it wants, how it wants.
See here:
Transferring information between two forms, Part 1: Parent to Child[
^]
All you need to pass the Form2 is the ID value: it collects what infor it needs to from the DB, and displays it without Form1 needing to know how it works:
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
DataGridView dgv = sender as DataGridView;
if (dgv != null && e.RowIndex >= 0)
{
int id = (int)dgv.Rows[e.RowIndex].Cells["ID"].Value;
Form2 form2 = new Form2(id);
form2.Show();
}
}
Or
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
DataGridView dgv = sender as DataGridView;
if (dgv != null && e.RowIndex >= 0)
{
int id = (int)dgv.Rows[e.RowIndex].Cells["ID"].Value;
Form2 form2 = new Form2();
form2.ID = id;
form2.Show();
}
}