I have a checkedListBox in a form's tabControl. In the checkedlListBox there are several items that can be selected.
When the user clicks the button below the checkedListBox, a loop is thrown that checks to see if it has selected items or not, if it was, the user is redirected to another tabPage.
If you did not select any option, the MessageBox appears. But the big problem is that this is only for the first item in the checkedListBox.
If you select the second or third and so on, the MessageBox appears as if the user had not selected anything.
So, going back to the title: how to go through all the items in a checkedListBox?
Code that is working with the first item:
private void btnEditarValores_Click(object sender, EventArgs e)
{
for (int i = 0; i <= (ListBoxSAdicionais.Items.Count - 1); i++)
{
if (ListBoxSAdicionais.GetItemChecked(i))
{
this.tabControl1.TabPages.Add(dados3);
this.tabControl1.SelectTab(2);
break;
}
else if ((ListBoxSAdicionais.GetItemChecked(i) == false))
{
MessageBox.Show("Você deve selecionar algum Status Adicional para editar os valores.");
break;
}
}