Form.DesktopLocation 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置窗体在 Windows 桌面上的位置。
public:
property System::Drawing::Point DesktopLocation { System::Drawing::Point get(); void set(System::Drawing::Point value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Point DesktopLocation { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.DesktopLocation : System.Drawing.Point with get, set
Public Property DesktopLocation As Point
属性值
一个 Point 表示窗体在桌面上的位置。
- 属性
示例
以下示例设置窗体的位置,以便窗体从桌面的左边框定位 100 像素,以及桌面顶部的 100 像素。 此示例要求已在窗体类中定义方法。
public:
void MoveMyForm()
{
// Create a Point object that will be used as the location of the form.
Point tempPoint = Point( 100, 100 );
// Set the location of the form using the Point object.
this->DesktopLocation = tempPoint;
}
public void MoveMyForm()
{
// Create a Point object that will be used as the location of the form.
Point tempPoint = new Point(100,100);
// Set the location of the form using the Point object.
this.DesktopLocation = tempPoint;
}
Public Sub MoveMyForm()
' Create a Point object that will be used as the location of the form.
Dim tempPoint As New Point(100, 100)
' Set the location of the form using the Point object.
DesktopLocation = tempPoint
End Sub
注解
桌面坐标基于屏幕的工作区,不包括任务栏。 桌面的坐标系基于像素。 如果应用程序在多监视器系统上运行,则窗体的坐标是组合桌面的坐标。
可以使用此属性将窗体相对于Windows桌面上的其他窗体和应用程序定位。
如果在调用SetDesktopLocation该方法之前调用Show该方法,窗体将定位在其默认位置,由操作系统确定。 有关窗口定位的详细信息,请参阅“窗口功能”一文的 “窗口大小和位置 ”部分。
如果在呼叫后进行呼叫SetDesktopLocationShow,您的表单将定位在指定的位置。