的WinForms:关闭模式对话框时,对话框之外点击对话框、模式、WinForms

2023-09-03 00:46:32 作者:好听的

我有一个开放的模态对话框(Windows窗体)。我想,该对话框关闭对话框之外点击(父窗体上)时。我该怎么办呢?

I have an open modal dialog (Windows Forms). I want, that the dialog is closed when clicking outside the dialog (on the parent form). How can I do that?

推荐答案

您应将其更改为一个无模式对话框(与打开展(..))然后使用停用事件,并将其关闭。

You should change it to a non-modal dialog (open it with Show(..)) and then use the Deactivate event and close it.