小哥哥小姐姐觉得有用点个赞呗!
C#指定窗口显示位置的方法
1.使用StartPosition
MainForm mainform;
mainform=new MainForm ();
dlgCtrl.StartPosition = FormStartPosition.Manual;
下面是FormStartPosition里边的定义与解释
// 指定窗体的初始位置。
public enum FormStartPosition
{
// 窗体的位置由 System.Windows.Forms.Control.Location 属性确定。
Manual = 0,
// 窗体在当前显示窗口中居中,其尺寸在窗体大小中指定。
CenterScreen = 1,
// 窗体定位在 Windows 默认位置,其尺寸在窗体大小中指定。
WindowsDefaultLocation = 2,
// 窗体定位在 Windows 默认位置,其边界也由 Windows 默认决定。
WindowsDefaultBounds = 3,
// 窗体在其父窗体中居中。
CenterParent = 4,
}
2.直接在窗口属性窗口更改属性
在属性的StartPosition 与Location更改
3.使用Location更改目标位置
使用location设置窗口显示位置。
MainForm mainform;
mainform=new MainForm ();
mainform.Location = new Point(500, 200);