I have a mainForm and a saveForm.
I never close the mainForm, just let the saveForm appear over the top.
When i close the saveForm, I want a piece of code to run on returning to mainForm.
What is the best way to achieve this?
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.
In addition to @benPearce’s answer, if you are content to have saveForm appear modally, then you can just call:
So in the
mainForm, I am assuming you have a Save button (let’s call itbtnSave) of some kind that brings upsaveForm, right? Right. So double click on that Save button and Visual Studio will create an event handler for you. Type in the code below.Of course, you have to make sure that the saveForm is setting the DialogResult. For instance, assuming you have an OK button in the
saveFormthat is supposed to close thesaveForm… In the Click event for the OK button you would do this: