• Create Account

### #ActualDrakken255

Posted 19 October 2012 - 07:37 AM

So the following should work:

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)
{
}

File.WriteAllLines(<FILE>, checkedItems.ToArray<string>());


List<string> checkedItems = new List<string>();

for (int i = 0; i < checkBoxList.Items.Count; i++)
{
if (checkedItems.Contains(checkBoxList.Items[i].ToString())
{
checkBoxList.SetItemChecked(i, true);
}
}


### #3Drakken255

Posted 19 October 2012 - 07:35 AM

So the following should work:

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)
{
}

File.WriteAllLines(<FILE>, checkedItems.ToArray<string>());


List<string> checkedItems = new List<string>();

for (int i = 0; i < checkBoxList.Items.Count; i++)
{
if (checkedItems.Contains(checkBoxList[i].ToString())
{
checkBoxList.SetItemChecked(i, true);
}
}


### #2Drakken255

Posted 18 October 2012 - 07:01 PM

So the following should work:

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?

### #1Drakken255

Posted 18 October 2012 - 06:58 PM

So the following should work:

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?

PARTNERS