2016-07-11 3 views
1

私は、アプリケーションを終了するときにテキストボックスにあるテキストを保存するプロジェクトを作成しています。データがテキストボックスに保存されないプロパティ.settings

下記のコードで見られるように、app.configにテキストデータを保存しようとしていますが、アプリケーションを閉じて実行すると、そこに置かれたテキストは表示されません。

イム本当に混乱しているため、フォームがロード、実行時にこの

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

とフォームが

Properties.Settings.Default.SavedText = textbox1.Text Closingイベントを呼び出しているときには、保存されている「保存されたテキストを」プルアップすべきです。
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を選択します。

関連する問題