I am writing a search form for desktop application and I have a problem with combobox binding.
The user can search for properties by various criteria (city, price, etc).
I want to bind combobox to list of all possible cities, but I want to leave the user the option not to choose anything so it can search properties in all cities.
How can I do that?
I’m using linq2sql for data access.
I am writing a search form for desktop application and I have a problem
Share
Well, supposing you have bound the combobox to a List of Cities that you pulled from your database:
Just Add an empty city to that list:
When you bind the combobox to the cityList and sort it, the city with id “AA” will be on top. In your searching code you can now adjust your search algorithm for the case that the user has selected the city with id “AA”;
Cleverer solutions are certainly possible, but I would need to see some code of the searching method to help you further.