Hi Guys

I was just wondering how you stop the combo box from displaying different instances of the same value.

In the combo box i have villages and towns names e.g doolin. onli thing is i have many businesses from doolin on the database so when i pull the town field for the combo box i get doolin in the cobmo box several times.

How do I prevent this??

Thanks

You probably have to eliminate the duplicates from the data you are inserting into the combo box.
One way to eliminate dups is to add all your data to a Set (eg TreeSet,use the addAll method) because Sets don't contain duplicates. Then you can simply convert the Set to an array (toArray method) and use that array to populate the combo box. The code is shorter than this description!

What do you mean elimnate duplicates?? Cause if u mean take them out i can't really do that as the town nd village are the onli field unique enough to do a legitmate search.

See there not really duplicates each business has to have a town or it won't be found ever inless i physically go through the database to find it so a place like doolin will have 30 B&Bs so when i fill the combobox with the town field i get doolin showing up thity times but i want it to show up onli once and be used as a reference for the thirty b&b do get what i mean??

OK, that's what I thought you meant. So like I said earlier, get your list of towns, remove the dups, put that list into the combo box.

This article has been dead for over six months. Start a new discussion instead.