为什么表单位置与设置位置不对应?
以下是代码:
[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);
答案 0 :(得分:2)
确保将StartPosition设置为手动:
form.StartPosition = FormStartPosition.Manual;