2

为什么表单位置与设置的位置不对应?

这是代码:

[STAThread]
static void Main(string[] args)
{
//stuff (.....)
MyForm form = new MyForm ();
form.WindowState = Settings.Default.MainFormWindowState;
//When the form is shown, it location will be != of Settings.Default.MainFormLocation. Why?
//The idea is to change the form location before it is first shown.
form.Location = Settings.Default.MainFormLocation;
form.Size = Settings.Default.MainFormSize;

Application.Run(form);
4

1 回答 1

2

确保将 StartPosition 设置为手动:

form.StartPosition = FormStartPosition.Manual;
于 2013-07-26T18:35:42.010 回答