答案 0 :(得分:0)
尝试将大小调整代码放入构造函数而不是Load
事件中。不要认为FormBorderStyle
需要相当大(这在.NET Compact Framework中是否支持,我假设您正在使用它?)。我们的表单风格为FixedDialog
。如果您需要使表单居中,可以使用此助手功能,在设置大小后立即调用:
public static void SetFormPosition(Form frmChild)
{
// Set the form position on the Windows CE panel
if (frmChild != null)
{
// Get the size of the screen (should be 480x768)
Rectangle rctScreen = Screen.PrimaryScreen.WorkingArea;
// Now calculate the position of the form
int nPosX = ((rctScreen.Width - frmChild.Width) / 2);
int nPosY = ((rctScreen.Height - frmChild.Height) / 2);
// Set the position
frmChild.Location = new Point(nPosX, nPosY);
}
}