2013-07-26 59 views
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); 

回答

2

確保將中StartPosition設置爲手動:

form.StartPosition = FormStartPosition.Manual; 
+0

從來沒有聽說過這件事!哈哈,完美的作品!謝謝! – Pedro77