Forums - C# Corner

Forum guidelines
Sri

Sri

  • 0
  • 19
  • 0

Loop through combo box items

Jul 8 2008 11:44 AM

Q1) What is the easy way to loop through the collection of items in the combo box?

Q2) What is the easy way to select a combo box item by value?

Some attempts related to Q2:

private object FindCbItemByValue(ComboBox cb, object val)

{

object oldval = cb.SelectedValue;

cb.SelectedValue = val;

object item = cb.SelectedItem;

cb.SelectedValue = oldval;

return item;

}

I do not want this since this fires the SelectedIndexChanged event of the combo box. So, I was thinking I had better loop through the collection. I had greatly appreciate if anyone knowledgeable can address this and guide me in the right direction.


Answers (10)

techbash 2016

SPONSORED BY

File APIs for .NET
Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!