Good day to all. I have a question, i’m using wpf and i cant find the right way of closing the form1 from form2.
WpfForm form1 = new WpfForm();
form1.close();
Please i need help.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need a reference to your first form in your second. Then you can simply call close using that reference.
There are a few ways to handle it. You could add a property to your second form to hold a reference to your first form. When you create your second form, you will set that property and then in whatever the event in your second form is supposed to close the first form (e.g. clicking a button), you can use that reference to close the form.