Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm developing a win app and somewhere i have to insert items to the combobox. But when i restart the app, the items are not there anymore I used a string collection for saving them. Of course it reads the items but it doesn't save the settings in it. Here is my code Thanks for your helps.

in my 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);
}
}
}

in my form_closing

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();
}
I have also add and remove some strings to the value of string collection at first.<

What I have tried:

I have also add and remove some strings to the value of string collection at first.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900