2016-07-11 6 views
1

저는 응용 프로그램을 닫을 때 텍스트 상자에있는 텍스트를 저장하려는 프로젝트에서 작업 중이며, 응용 프로그램을 다시 열면 해당 텍스트가 있어야합니다.데이터가 텍스트 상자에 저장되지 않습니다. properties.settings

아래 코드에서 볼 수 있듯이 app.config에 텍스트 데이터를 저장하려고하는데 응용 프로그램을 닫고 실행하면 입력 한 텍스트가 없습니다.

임 정말 혼란 때문에 폼이로드가 실행될 때이

textbox1.Text = Properties.Settings.Default.SavedText;

하고 최대 양식이 closing 이벤트

를 호출 할 때 저장되고있는 "저장된 텍스트"당겨해야

Properties.Settings.Default.SavedText = textbox1.Text;
Properties.Settings.Default.Save();

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 
using MetroFramework; 
using MetroFramework.Forms; 

namespace WindowsFormsApplication1 
{ 
    public partial class Form1 : MetroForm 
    { 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void Form1_Load(object sender, EventArgs e) 
     { 
      textbox1.Text = Properties.Settings.Default.SavedText; 
     } 

     private void Form1_FormClosing(object sender, FormClosingEventArgs e) 
     { 
      Properties.Settings.Default.SavedText = textbox1.Text; 
      Properties.Settings.Default.Save(); 
     } 
    } 
} 

는 또한 전에 이러한 오류를 받고 있었고, 난 잠재적 인 수정을 보여주는 시도하고 사용하지만 텍스트가 저장되지 함께 문제를 해결 didnt한다. enter image description here

이것은 잠재적 인 수정 프로그램입니다. enter image description here

답변

1

내 프로젝트 속성으로 이동하여 프로젝트 설정에 추가하여 문제를 해결했습니다. SavedText> String> User를 선택합니다.

관련 문제