vb.net 获取实际形态的 X/Y 点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8696690/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get X/Y point of the actual form
提问by Florian Müller
Simple question, but could somehow not find any answer on google (maybe it's just too late):
一个简单的问题,但不知何故在谷歌上找不到任何答案(也许为时已晚):
How can I get the coordinates of a form (current form => Me
) of the upper left angle of it on the screen?
如何获取Me
屏幕左上角的表单(当前表单 => )的坐标?
Thanks for help!
感谢帮助!
回答by Mitch Wheat
Dim p as Point
p = Form1.Location
Debug.Print(p.X)
Debug.Print(p.Y)
If you want to set a form's location:
如果要设置表单的位置:
frm.Location = New Point(100, 300)
回答by Gerald P. Wright
In VB.NET the location of a form can be found using Me.Location.
在 VB.NET 中,可以使用 Me.Location 找到表单的位置。
You can set it using
您可以使用它进行设置
Me.Location = new Point(100,200)
or get the location using
或使用获取位置
Dim Value as Point
Value = Me.Location;