2011-08-26 81 views
0

我已經創建了splitterLocation設置,輸入system.Drawing.Point和Scope:User。當用戶改變時保存分離器位置。並在表單加載時重新加載新位置。SplitterLocation不保存在設置

private void splitter1_LocationChanged(object sender, EventArgs e) 
    { 
     MailSystem.Properties.Settings.Default.splitterLocation = splitter1.Location; 
     MailSystem.Properties.Settings.Default.Save(); 
    } 

private void Form1_Load(object sender, EventArgs e) 
    { 
     splitter1.Location = MailSystem.Properties.Settings.Default.splitterLocation; 
    } 

但它不工作我不知道爲什麼?

回答

1

嘗試將保存代碼移至FormClosing事件。

private void Form1_FormClosing(object sender, EventArgs e) 
{ 
    MailSystem.Properties.Settings.Default.splitterLocation = splitter1.Location; 
    MailSystem.Properties.Settings.Default.Save(); 
} 

並確保您的splitter1控件沒有停靠DockStyle.None。

+0

是的問題是,它停靠了。謝謝 –