Hey I'm new to programming and to the forum. I am creating a simple inventory system that uses both modal and non-modal forms. My challenge is I created a change password form (modal) and it has a 'change password' button as well as a 'cancel' button. When i click cancel, it closes everything. I dont want that I only want the change password form to close leaving the parent form in view. I have search high and low but the help that I got (this.close, dispose) does not work. I even changed the dialogResult property to cancel but that didnt work either. How do I accomplish this?

Depends on how you've coded the logic of the form. this.Hide() should do what you want.

I tried that but it didnt really hide it was still there its just that you cannot interface with it because of how modal forms operate. I want it to be removed from view totally and should only be seen if I bring it back. Any other suggestions?

When you Hide the form it is no longer visible. I have no idea what you think you are doing, but it isn't calling Hide on the form.

I'm thinking that perhaps you're coding and the set up of your properties might be out. With accept and cancel assigned on the modal form and this.Close(); in the click event of the cancel button, just the modal form closes, not the parent. when testing this I also set the isMDIParent to true on the parent form.

What is the first form of your project? Is it an MDI parent?

@samsylvestertty, no its not. The MDI thing was giving me some problems in order to do what I wanted so thats how I used modal forms. If I set the parent form to MDI, it will mess up the design.

I tried to reproduce the problem you posted but couldn't. This link seems to be identical to your problem. Check that....

This is a code snippet I posted some time ago. I hope it can help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.