Thursday, April 7, 2011

How to iterate through a combobox's items and match a string function?


A better idea just count the element in the combo box and iterate through their index .

private bool checkid(string str )
        {
            bool k = false;
            for (int i = 0; i < cmbmsiid.Items.Count;i++ )
            {
                if (cmbmsiid.Items[i].ToString() == str)
                {
                    k = true;
                    break;
                }
            }
            return k;
        }

1 comment:

  1. foreach (string email in checkedListBox2.Items)

    {
    }

    just do it

    ReplyDelete