I have two requirements regarding a combobox.
First is:

I am trying to store a new item into a combobox which in turn will store in a xml file. But the problem is i need to store only unique values in xml file. I had used foreach statement to solve the issue but it doesn't work. Is there any other method?

Second is:

I have to insert a item into a datagridview whenever a item is selected on a button click. Here also i need to check in datagrid whether the item is present already.

Note : for loop works only when there is no item in the datagrid. By default am retrieving some items from datagridview (i.e 3 items)..

Hi

Try :
Step 1: get the value you want to add into the combobox
Step 2(a): use a search algorithm to test if your collection already contains such data (in this case combobox) or
Step 2(b) : use linq to query the collection and test if it already exists.
Step 3: you can now decide what to do since you know whether its exists or not.

Thanks
Ask if anything is not clear