如何在第二个监视器中弹出C#winform消息框 [英] How to popup C# winform message box in second monitor

查看:124
本文介绍了如何在第二个监视器中弹出C#winform消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个winform应用程序,两个应用程序在一台PC和两个不同的监视器上运行。当我点击第二台显示器的第二个winform上的按摩按钮,第一台显示器上的按摩盒弹出窗口。



我尝试了什么:



我在第二个应用程序上尝试了这个代码,但它有时会工作。不是所有的时间。



this.Location = Screen.AllScreens [1] .WorkingArea.Location;

I have two winform application and both two application running on one PC and two different monitors. When I click on massage button on second winform of second monitor that massage box popup on first monitor.

What I have tried:

I have try this code on second application but it's work sometimes. not all the time.

this.Location = Screen.AllScreens[1].WorkingArea.Location;

推荐答案

你可以给一个对象句柄作为第一个参数,如下所示:

You can give an object handle as the first parameter, like this:
Show(IWin32Window, String)

一个简单的例子:

A simple example:

var result = MessageBox.Show(this, "Hello there !");



更多信息: MessageBox.Show方法(System.Windows。表格)| Microsoft Docs [ ^ ]


您是否尝试过MessageBox.Show(...)中的MessageBoxOptions
Did you try MessageBoxOptions in MessageBox.Show(...)


这篇关于如何在第二个监视器中弹出C#winform消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆