c# - 新窗口打开后的位置

标签 c# winforms window

我尝试每次都在相同位置用 C# (WinForms) 打开新窗口。 尝试使用此代码:

private void Notification_Load(object sender, EventArgs e)
{
    Rectangle screenSize = Screen.PrimaryScreen.Bounds; //get resolution of screen
    int x = screenSize.Height -115-30; //x coordinate = resolution of screen - window Height - 30 (for taskbar)
    int y = screenSize.Width - 345; //y coordinate = resolution of screen - window Weight
    this.SetDisplayRectLocation(x, y); //new coordinates for form
}

窗口属性 StartPosition =Manual

但结果 - 让我的窗口始终在左上角打开。

尝试为 x 和 y 设置不同的值 - 结果相同。

我做错了什么?

最佳答案

希望对你有帮助

 int x = Screen.PrimaryScreen.WorkingArea.Top;
 int y = Screen.PrimaryScreen.WorkingArea.Left;
 this.Location = new Point(x, y);

关于c# - 新窗口打开后的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18556538/

相关文章:

c# - ml.net 中分类数据的聚类

c# - XAML - 应用栏中菜单项下的额外空间

c# - 如何从 linq 表达式中获取字符串?

c# - 检查 null 并在没有时分配另一个值的最短方法

c# - 以编程方式选择 DataGridView 中的一行

winforms - 具有相同数据源的两个控件的问题

wpf - 如何从 View 模型(Caliburn+WPF)关闭对话框窗口?

matlab - 在命令行窗口中禁用 Matlab 中的启动提示?

c# - 从 C# Winforms 更新表不工作

jquery - 响应式方形图像重复以平均填充窗口空间