0

Im trying to save the items in the listbox in Settings.Default but it will not work, this is what i have so far.

test.Properties.Settings.Default.list = listBox1.Items;

2 Answers2

1

Changes to properties will not persist if you don't call Save() afterwards.

test.Properties.Settings.Default.list = listBox1.Items;
test.Properties.Settings.Default.Save();
ean5533
  • 8,884
  • 3
  • 40
  • 64
1

Have you tried with an ArrayList?

test.Properties.Settings.Default.list = new ArrayList(listBox1.Items);
test.Properties.Settings.Default.Save();

Then you could load the list back like so:

listBox1.Items.AddRange(test.Properties.Settings.Default.list.ToArray());

I'm also assuming that the items in your list are serializable (either implement ISerializable or have the SerializableAttribute).

Mario S
  • 11,715
  • 24
  • 39
  • 47