OPM*_*ato 16 c# position winforms
我在Visual Studio C#2010中编写WinForms应用程序,我想找出WinForm窗口左上角的位置(窗口的起始位置).
我怎样才能做到这一点?
Moo*_*ght 16
如果您从表单本身访问它,那么您可以编写
int windowHeight = this.Height;
int windowWidth = this.Width;
Run Code Online (Sandbox Code Playgroud)
获取窗口的宽度和高度.和
int windowTop = this.Top;
int windowLeft = this.Left;
Run Code Online (Sandbox Code Playgroud)
获取屏幕位置.
否则,如果您启动表单并从另一个表单访问它
int w, h, t, l;
using (Form form = new Form())
{
form.Show();
w = form.Width;
h = form.Height;
t = form.Top;
l = form.Left;
}
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助.
小智 6
检查这个: Form.DesktopLocation 属性
int left = this.DesktopLocation.X;
int top = this.DesktopLocation.Y;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
43182 次 |
| 最近记录: |