Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing form (dialog) called from form (dialog) closes both!

Status
Not open for further replies.

CraigBest

Programmer
Aug 1, 2001
545
0
0
US
Hi folks

Wondering if someone can help me out here with a problem I am not sure how to fix...

In an app I'm working on, a user can click a button and bring up a form that is displayed by calling form1.ShowDialog(). On that form, I've added another button to bring up a form (form2) that is also called with the .ShowDialog method. Displaying both forms works fine. However...

When I want to close the second form, I use the command Me.Close. This closes form2 but it also closes form1! Not sure why this is happening, but would like to stop it and leave form1 open when form2 closes. Any indea how I can do that?

Thanks

Craig

CraigHartz
 
You really need to show your code if you want help. I can't say 100% what might be happening without code, but .ShowDialog only keeps the form open till a Dialog response is received. In some way it must be coded that your responding. Check what if anything the AcceptButton property and CancelButton property are set to. Generally speaking you want to use .Show on a form not .ShowDialog and you normally do not chain Dialog boxes. There is nothing technically wrong with doing so it is just not a standard programming practice.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Hi Sorwen

OK, thanks - unfortunately it isn't up to me about the original form, I can't change it (not my work and not in the scope of what I can do) but I did determine that there are other 'function' buttons on the same form that also call dialog mode windows, and when they close the same thing happens (as you might expect). So since ther is precedent I'm not going to worry about it. Good to know, though, that this is expected behavior. It was just very surprising!

CraigHartz
 
Yeah, if there is nothing you can do then there is nothing you can do. I'm lucky that I'm always lead on any project I do even when my boss is part of it. Generally speaking though we handle 1 man projects with just longer development times since we deal with highly specialized programs. I'm also given a lot of leway between projects to make tools to help our process go faster. The down side is neither of us has the pay or title for the work we actually do. Still that means we get to be part of a better deparment then others, so it is give and take. :)

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top