[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

problems using modal forms

Hi everybody.

I got a problem regarding modal forms. see, i have loaded(showdialog) a modal form. now this form has a button that loads(showdialog) another modal form. The problem is, when i close the 2nd modal form. The modal form that called the 2nd also closes. i cant seem to get around this behavior. My code is something like this:

Form1 f1 = new Form1();
Form1.Owner = this; // 'this' is an MDIForm            
Form1.ShowDialog();

on button click on form1:

form2 f2 = new form2();            
f2.Owner = this; // even if this is omitted, the f1 still closes when you close f2 via the 'X' button
f2.ShowDialog();

Please help. Thanks.
0
manduz_griffus
Asked:
manduz_griffus
  • 3
  • 2
1 Solution
 
Bob LearnedCommented:
That is the behavior when you set the Owner of the form--all child forms close also, but I didn't think it was when you don't set it, so is MdiParent set?

Bob
0
 
manduz_griffusAuthor Commented:
Thanks for the reply but what im having is when i close the modal child, the modal parent also closes. And what made it more confusing is that when i created a new project where there are 3 forms(one mid parent with button to show a modal form, and this modal form also has a button that showa another modal form), the problem behavior does not happen. ive got no extra codes on the original project, same form properties, but when i close the 3rd form(the most modal form), the 2nd form also closes. what could be the cause of this behavior?
0
 
Bob LearnedCommented:
Did you set MdiParent for the child?

Bob
0
 
manduz_griffusAuthor Commented:
hi bob, ive benn doing some browsing, and it seems that it has something to do with the dialogresult object. still not sure though. the child, by the way, is not an mdichild since it is modal. any thoughts?
0
 
manduz_griffusAuthor Commented:
hi, ive found the solution. it was the buttons dialogresult property. it was set to cancel. thanks for the replies, man.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now