選表單的Porject/Add Reference,加入 System.Configuration
範例:
using System.Configuration;
namespace AppConfigExample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
int num = Properties.Settings.Default.Num;
textBox1.Text = Convert.ToString(num);
}
private void button1_Click(object sender, EventArgs e)
{
int num = Convert.ToInt32(textBox1.Text);
Properties.Settings.Default.Num=num;
Properties.Settings.Default.Save();
}
}
}
不錯的文章:
http://wlchang1108.blogspot.tw/2016/08/visual-studioproertiessettingssettings.html
https://dotblogs.com.tw/yc421206/2010/08/08/17076
沒有留言:
張貼留言