csharp_learner
asked on
Close parent and child Form C#
Hi, I'm currently handling with 3 Forms.
A Main Form,Parent Form and a child Form.
The relation is the Main form has a link to the parent form.
The Parent Form links to a Child Form after a button event.
My question is How can Close the ChildForm and ParentForm at the same time when I close the ChildForm?
A Main Form,Parent Form and a child Form.
The relation is the Main form has a link to the parent form.
The Parent Form links to a Child Form after a button event.
My question is How can Close the ChildForm and ParentForm at the same time when I close the ChildForm?
//Main Form link
parentForm Pdetails = new parentForm();
Pdetails.ShowDialog();
Pdetails.Dispose();
//Parent Form
childForm Cconfirm = new childForm(confirmlist);
Cconfirm.Show();
//Child Form (How to close ParentForm also???)
this.DialogResult = DialogResult.Cancel;
this.Close();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
my bad MyChildForm child = new MyChildForm(this); worked.
ASKER
private void newDataPoint_Click(object sender, EventArgs e)
{
MyChildForm child = new MyChildForm();
child.ShowDialog();
child.Dispose();
}
"MyChildForm child = new MyChildForm();"does not take '0' arguments.What should I include inside?
I tried MyChildForm child = new MyChildForm(this); but doesn't work