I have an app in C# that needs two list boxes, but the contents of them are populated according to the state of some checkboxes. I have already figured out how to add content to the list box when the checkbox gets checked, but I want the app to remove that same content if the same checkbox gets unchecked.
NOTE: The Listbox is NOT a checked listbox... it's just a plain listbox. I spent a lot of time looking (in the wrong places, I guess...) and I can't find anything for my specific issue here...
The function I have looks like this:
private void cbCheckbox_CheckedChanged(object sender, EventArgs e)
{
if (cbCheckbox.Checked)
{
testlist.Add("Elemento1");
testlist.Add("Elemento2");
testlist.Add("Elemento3");
ltTestPool.DataSource = testlist;
}
else
{
testlist.Add("Elemento1");
testlist.Add("Elemento2");
testlist.Add("Elemento3");
ltTestPool.DataSource = testlist;
}
}