2014-09-07 4 views
1

NumericUpDown-Box의 Mouse X 및 Mouse Y 좌표를 Settings.settings에 저장하여 프로그램에서 마지막으로 사용한 값으로 시작하도록 프로그램을 만들고 있습니다.Visual C# - Properties.Settings가 올바르게 저장되지 않습니다.

모두 입력 박스는 방법 "saveXY"를 호출 할 때 "의 valueChanged"as seen here

내 문제은 : X가 문제없이 구원을 얻을 좌표의 Y 좌표를 전혀 저장되지 않습니다 -하지만 코드가있다 같은 :

private void Form1_Load(object sender, EventArgs e) 
    { 
     movetoX.Value = Settings.Default.mouseX; 
     movetoY.Value = Settings.Default.mouseY; 
    } 

-

private void saveXY(object sender, EventArgs e) 
    { 
     Settings.Default.mouseX = (int)movetoX.Value; 
     Settings.Default.mouseY = (int)movetoY.Value; 
     Settings.Default.Save(); 
    } 

Theese 내 Settings.settings 있습니다.

.exe는 사용할 수 있습니다. here입니다.

+0

저장하지 않으시는 것이 무엇을 의미합니까? Visual Studio에서 앱을 실행합니까? –

+0

Strg + F5 키를 눌러 실행합니다. MouseX는 Settings.settings에 저장되지만 MouseY는 저장되지 않습니다. 다음은 테스트 용 .exe입니다. http://workupload.com/file/C6FSEuiA –

+0

다른 스레드에서 UI를 업데이트 한 것을 확인합니다. 왜 예외가 발생하지 않는지 모르겠다. Thread 클래스를 사용하지 말아라. –

답변

0

감사는 이제 saveXY을 삭제

작업, hamix이 쓴하기 : 지금 X와 Y를 저장

private void Form1_FormClosed(object sender, FormClosedEventArgs e) 
    { 
     Settings.Default.mouseX = (int)movetoX.Value; 
     Settings.Default.mouseY = (int)movetoY.Value; 
     Settings.Default.Save(); 
    } 

0

이 문서는 유용 할 수 있습니다. http://msdn.microsoft.com/en-us/library/aa730869%28v=vs.80%29.aspx

업데이트 1 :

는 Properties.Settings.Default.Upgrade() 다음 저장된 설정로드받을를 수행했다.

샘플

public Form1() 
{ 
    InitializeComponent(); 
    //Load saved settings 

    this.Location = Properties.Settings.Default.Form1Location; 
    this.Size = Properties.Settings.Default.Form1Size; 
    //Allow changes to be implemented 

    this.StartPosition = FormStartPosition.Manual; 
    //capture changes 

    this.LocationChanged += new EventHandler(Form1_LocationChanged); 
    this.SizeChanged += new EventHandler(Form1_SizeChanged); 
    //capture the closing form event to save your new settings 

    this.FormClosed += new FormClosedEventHandler(Form1_FormClosed); 
} 
void Form1_LocationChanged(object sender, EventArgs e) 
{ 
    //Capture the new values 

    Properties.Settings.Default.Form1Location = this.Location; 
} 
void Form1_SizeChanged(object sender, EventArgs e) 
{ 
    //Capture the new values 

    Properties.Settings.Default.Form1Size = this.Size; 
} 
void Form1_FormClosed(object sender, FormClosedEventArgs e) 
{ 
    //you can capture the new values here as well  
    //save the new values 

    Properties.Settings.Default.Save(); 
} 
+0

내 값은 저장되지만 다른 값은 저장하지 않는다 :/ - 그리고 이유는 모르겠다. –

+0

내 업데이트 읽기 1 – Hamix

+0

와우, 그 FormClosed 존재하지 않았다. –

관련 문제