如何停靠在C#Windows窗体? [英] How to dock a windows form in C#?

查看:148
本文介绍了如何停靠在C#Windows窗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道是否有可能停靠在用户屏幕上方的窗口形式?我一直在试图通过我的表单的位置手动设置我想要的坐标来做到这一点。但是使用这种方法,然而,允许用户仅通过拖动它来改变的形式的位置。我想要停靠,因为这个窗口表格将服务器设置为我做这个项目的菜单屏幕的上半部分的形式。

I just would like to know if it is possible to dock a windows form on top of the user screen? I have been trying to do this by manually setting the position of my form to the coordinates I want. But using this method, however, allows the user to change the position of the form just by dragging it. I want to make the form docked to the upper portion of the screen since this window form will server as a menu for the project I am making.

非常感谢。 :)

推荐答案

因此,一些调整后,我终于能得到这个代码的工作。

So after some tweaks I finally was able to get this code working.

this.DesktopLocation = new Point((Screen.PrimaryScreen.Bounds.Width / 2 - 420), 0);



我放置在InitializeComponent()低于该行和它船坞我的形式在屏幕上的与中心无论分辨率值。

I placed that line below the InitializeComponent() and it docks my form to the center of the screen with whatever resolution values.

这篇关于如何停靠在C#Windows窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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