Click here to Skip to main content
15,923,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In Form1 i add DataGridView and it contents 10 rows. and column[5] is CheckBox, and this CheckBox is ReadOnly.
Now i want to do that:
when double click on Row1 the Form2 open and Checkbox checked, and when close Form2 the Checkbox unchecked, ect.

What I have tried:

I tried this, but i can't tried foreach in Frm_Closing:
C#
private void datagridview1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
    Form2 form = new Form2();
    if (datagridview1.CurrentRow.Cells[5].Value == null)
    {
        datagridview1.CurrentRow.Cells[5].Value = true;
        form.MdiParent = this.MdiParent;
        form.Show();
        form.Closing += Frm_Closing;
    }
    else
    {
        form.Activate();
        form.BringToFront();
    }
}
Posted
Updated 21-May-21 21:19pm
v2

1 solution

Do yourself a favor and don't use MDI, it will only give you headaches.
I also would recommend to declare form outside the method at the begin of your class like this:
private Form2 form;
 
Share this answer
 
v3
Comments
User_Michel 22-May-21 5:04am    
Thank you, but Form1 must be like Main form. i think this is not the problem in this case.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900