作者don750421 (1+1≠2)
看板C_Sharp
标题[问题] Applicationsettings储存设定
时间Thu Nov 10 23:34:03 2011
想请问一下applicationsettings可以储存datatime和combobox的值吗?
因为我想要选了一个日期,假设我选2011年11月10日
并且combobox下拉了一个值。那我可以藉由applicationsettings储存吗?
但是我是写一个checkedbox,如果有勾选择储存
但是好像没办法...不知道是不是我写错?
namespace Date
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Controls.Add(comboBox1);
comboBox1.KeyPress += new
KeyPressEventHandler(comboBox1_KeyPress);
}
private void Form1_Load(object sender, EventArgs e)
{
system.datetime indate = Properties.Settings.Default.indate;
system.datetime outdate = Properties.Settings.Default.outdate;
string discount = Properties.Settings.Default.discount;
}
private void saveCheckBox1_CheckedChanged(Object sender, EventArgs e)
{
if (savecheckBox1.Checked)
{
Properties.Settings.Default.Save();
}
}
}
}
中间主要程式码太长了,就有些省略,不晓得是不是有地方写错呢?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.171.29.109
1F:→ knifehandz:没有更新到 Properties.Settings.Default.x 的值喔 11/11 03:20
2F:→ knifehandz:if (savecheckBox1.Checked) 也怪怪的,你定义的 11/11 03:21
3F:→ knifehandz:Settings 应该是 Boolean 吧,所以 T/F 都应该存进去 11/11 03:21
4F:→ knifehandz:而不是只有 true 的时候才更新 11/11 03:22
5F:→ don750421:k大的意思是?可是我的discount值有存进去,就日期没存 11/14 00:26
6F:→ knifehandz:Properties.Settings.Default.Save() 之前应该还要加 11/14 14:31
7F:→ knifehandz:Properties.Settings.Default.indate = indate ... 等 11/14 14:31