开发者

WinForms: child form closes parent form

开发者 https://www.devze.com 2023-03-17 21:48 出处:网络
In my C# project I have 2 modal dialogs (ParentForm and ChildForm): In ParentForm I\'m calling ChildForm:

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开发者_如何学C behaviour? Thanks.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消