int oldLength = settings.Length;
if (settings.Length < numberOfBoxes)
{
Array.Resize(ref settings, numberOfBoxes);
for (int i = oldLength; i < settings.Length; i++)
{
settings[i] = "false";
}
}
And then each time settings change I just modify the constant numberOfBoxes?
As it is I'm not yet comfortable with XML serialization. I currently use manual data storage with File.WriteAllLines(). I'm assuming it's a much better way to go in this situation?
EDIT: I seem to have found a solution involving a Checked List Box. I didn't want to make a separate file out of it, but oh well. When saving, I save with:
List<string> checkedItems = new List<string>();
foreach (object checkedBox in checkBoxList.CheckedItems)
{
checkedItems.Add(checkedBox.ToString());
}
File.WriteAllLines(<FILE>, checkedItems.ToArray<string>());
And Load with:
List<string> checkedItems = new List<string>();
checkedItems.AddRange(File.ReadAllLines(<FILE>));
for (int i = 0; i < checkBoxList.Items.Count; i++)
{
if (checkedItems.Contains(checkBoxList.Items[i].ToString())
{
checkBoxList.SetItemChecked(i, true);
}
}