Skip to content

Instantly share code, notes, and snippets.

@Mahno74
Last active July 6, 2021 10:38
Show Gist options
  • Save Mahno74/71cd691e9382152fe9f7c229bbe9973d to your computer and use it in GitHub Desktop.
Save Mahno74/71cd691e9382152fe9f7c229bbe9973d to your computer and use it in GitHub Desktop.
Загрузка и выгрузка состояний блока чекбоксов
//Cheked items to string:
string result = CheckedItemsToString(checkedListBox1.CheckedItems)
public static string CheckedItemsToString(CheckedListBox.CheckedItemCollection input)
{
List<string> values = new List<string>();
foreach (object o in input)
values.Add(o.ToString());
return String.Join(",\n", values);
}
//Set data from string and check corresponding fields in CheckedListBox
for (int y = 0; y < checkedListBox1.Items.Count; y++)
if (result.Contains(checkedListBox1.Items[y].ToString()))
checkedListBox1.SetItemChecked(y, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment