在与应用程序相同的屏幕上显示(弹出)消息框 运行

Display(pop-up) Message Box on the same screen as the application is running

我正在开发 c# winforms 应用程序。我正在积极使用 2 台显示器,即主要显示器和次要显示器。当我 运行 应用程序时,消息框总是在主监视器上弹出,而不管我 运行 应用程序在哪个监视器上。

下面显示的是我尝试过但消息框在主监视器上弹出的 2 种方法:

1.

MessageBox.Show("Test Success", "Success", MessageBoxButtons.OK, 
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, 
MessageBoxOptions.ServiceNotification);

2.

MessageBox.Show("Test Success", "Success", MessageBoxButtons.OK, 
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, 
MessageBoxOptions.DefaultDesktopOnly);

有什么方法可以在 运行 应用程序的监视器上动态显示消息框?

如评论中所述:不要指定MessageBoxOptions。简单地这样称呼它:

MessageBox.Show("Test Success", "Success", MessageBoxButtons.OK, 
                MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

它会出现在与您的应用程序相同的显示器上,就在它的前面。

I want to display the Message Box on top of any other apps I have opened.

然后你应该强制调用 MessageBox 的表单到表面。在显示消息框之前调用它:

this.TopMost = true;
MessageBox.Show(...