hi, my problem is, in the main form i want to click a button and two forms show dialog sync, and then in form3, in closed form event i want to close form2 . how should to do this?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
NarayanPosted Oct 3, 2011, 11:54 PM
Try to create a public delegate and add a property of its type it in the other form which you want to close. Then in the form closing event just invoke the delegate, you are done.
Mahdi GholamiPosted Oct 11, 2011, 1:59 AM
public delegate void closedelegate();
private void Form3_FormClosed(object sender, FormClosedEventArgs e){
foreach (Form frm in Application.OpenForms)
{
if (frm.Name == "Form2")
{
frm.invoke(new closedelegate(frm.Close));
break;
}
}
}