亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法將我的組合框項目保存到 appSettings 中的 MyStringCollection

無法將我的組合框項目保存到 appSettings 中的 MyStringCollection

C#
呼喚遠方 2021-11-28 16:14:52
我正在開發一個 win 應用程序,我必須在某個地方將項目插入組合框。但是當我重新啟動應用程序時,項目不再存在,我使用字符串集合來保存它們。當然,它會讀取項目,但不會將設置保存在其中。這是我的代碼感謝您的幫助。在我的 Form_load 中private void Services_Form_Load(object sender, EventArgs e){    if(Properties.Settings.Default.combo_items != null)    {        foreach (object items in Properties.Settings.Default.combo_items)        {            comboBox1.Items.Add(items);        }    }}在我的表單中 private void Services_Form_FormClosing(object sender, FormClosingEventArgs e){    if (Properties.Settings.Default.combo_items != null)    {        Properties.Settings.Default.combo_items.Clear();        foreach (string items in combo_Combobox_1.Items)        {            Properties.Settings.Default.combo_items.Add(items);        }    }    Properties.Settings.Default.Save();}我還首先在字符串集合的值中添加和刪除了一些字符串。
查看完整描述

1 回答

?
ITMISS

TA貢獻1871條經驗 獲得超8個贊

我有問題在哪里。在 Form_closure 中


private void Services_Form_FormClosing(object sender, FormClosingEventArgs e)

        {

            Properties.Settings.Default.combo_main_srvc.Clear();


            foreach (object items in combo_delete_main_srvc.Items)

            {

                Properties.Settings.Default.combo_main_srvc.Add(items.ToString());

            }

            Properties.Settings.Default.Save();

        }

我在foreach條件中替換了對象而不是字符串。


查看完整回答
反對 回復 2021-11-28
  • 1 回答
  • 0 關注
  • 197 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號