快速的问题,希望一个简单的解决方案。我对 C# 有点陌生,并试图在第二个表单打开时将其居中显示在辅助屏幕上。到目前为止,我可以让它在第二个屏幕上打开没问题,但它位于左上角,我无法让它居中。我知道Location = Screen.AllScreens[1].WorkingArea.Location;
将把它放在所述工作区的左上角。我想知道是否有办法(基本上)将其更改.Location
为其他无论实际屏幕尺寸如何都可以居中的东西?这将适用于具有不同屏幕尺寸的多个不同系统。这是我到目前为止的代码。
在第一个表格上。
public partial class FrmPrompt : Form
{
public FrmPrompt()
{
InitializeComponent();
}
private void ButNo_Click(object sender, EventArgs e)
{
frmConfirm confirm = new frmConfirm();
Screen[] screens = Screen.AllScreens;
lblConfirmMsg.Text = "Please Wait For Customer To Confirm...";
butContinue.Hide();
confirm.Show();
}
}
第二种形式:
public partial class frmConfirm : Form
{
public frmConfirm()
{
InitializeComponent();
Location = Screen.AllScreens[1].WorkingArea.Location;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
谢谢!