how to verify if a string exists in the comobox

Oct 11, 2010 at 2:35 PM

Hello,

I have a combo box drop down which cotains two items "ABC" and ""DEF" and i have to verify if "ABC" do exist in the combo box drop down.

Can someone please help me in hwo to verify that? Thanks,

Oct 12, 2010 at 5:39 AM

Let us assume combo name as testcombo

for(int iCnt=0;iCnt<testCombo.items.count;iCnt++)

{

if(testCombo.item(iCnt).text.equals("ABC",StringComparison.Ordinal))

{

//ABC exist

}

}

Oct 12, 2010 at 2:18 PM

Thanks Arun, do i need an else statement as well? what if  the item is not found? Thanks again for your help.

Oct 13, 2010 at 5:23 AM

bool valueExist = false;

for(int iCnt=0;iCnt<testCombo.items.count;iCnt++)

{

if(testCombo.item(iCnt).text.equals("ABC",StringComparison.Ordinal))

{

valueExist = true;

break;

}

}

 

Now else statement is not required ...outside  the loop if the ABC doesnt exist the valueExist will be false....

 

 

 

 

Oct 13, 2010 at 2:45 PM

Thank you Arun.