Skip to content

Parent/Child form issue

Dealy

Asked Mar 18, 2010, 11:10 PM EDTSolved
Share
LinkedInX
Hello,

i have the following code:
TypeScript
   private void searchDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            string passIDNO;
            passIDNO = searchDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
            Form1 form1 = new Form1(passIDNO, 1);
            form1.button1_Click(sender, e); // Retrieves data of Customer to Form1
            //form1.MDIParent = ????
            form1.Show();
         }

I have a ParentForm called MainForm and all my forms open inside MainForm. How can i make Form1 (which is called from Form2) opens inside MainForm as well?
(Form2 opens inside MainForm)

Thank you in advance.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Hirendra Sisodiya
    ✓ Accepted answer0
    try this:
    private void searchDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
    string passIDNO;
    passIDNO = searchDataGridView.Rows[e.RowIndex].Cells[1].Value.ToString();
    Form1 form1 = new Form1(passIDNO, 1);
    form1.button1_Click(sender, e); // Retrieves data of Customer to Form1
    form1.MDIParent = this.MdiParent;
    form1.Show();
    }
     
    thanks
    Please mark as answere if you like my answere
    0
  • 1 short reply
    • 0
      Thank you for the answer!
      0