看板 C_Sharp 關於我們 聯絡資訊
想請問一下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
knifehandz:沒有更新到 Properties.Settings.Default.x 的值喔 11/11 03:20
knifehandz:if (savecheckBox1.Checked) 也怪怪的,你定義的 11/11 03:21
knifehandz:Settings 應該是 Boolean 吧,所以 T/F 都應該存進去 11/11 03:21
knifehandz:而不是只有 true 的時候才更新 11/11 03:22
don750421:k大的意思是?可是我的discount值有存進去,就日期沒存 11/14 00:26
knifehandz:Properties.Settings.Default.Save() 之前應該還要加 11/14 14:31
knifehandz:Properties.Settings.Default.indate = indate ... 等 11/14 14:31