mxpv
mxpv

Reputation: 956

WinForms: child form closes parent form

In my C# project I have 2 modal dialogs (ParentForm and ChildForm):

In ParentForm I'm calling ChildForm:

        var ChildForm = new ChildForm ();
        if (DialogResult.OK == ChildForm .ShowDialog(this)) {
           ...

When I'm closing ChildForm the ParentForm is also closing automatically. How can I prevent such behaviour? Thanks.

Upvotes: 3

Views: 1605

Answers (1)

mxpv
mxpv

Reputation: 956

So, the solution to my problem: Some buttons on the ParentForm had the DialogResult property set to Cancel and because of this the ParentForm is closing after a click event is triggered.

Upvotes: 2

Related Questions