Click here to Skip to main content
15,945,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I currently have a DataGridView that displays items from a database, and I'm stuck on filtering all these items.

I used the query builder to make an SQL statement using
Subject LIKE ? + '%'
Topic LIKE ? + '%'
which filters via two textboxes. This works fine, however I'd much rather use Combobox's.

What I'm trying to do is use a Combobox for filtering instead of a textbox.
The first Combobox needs to have a list of all the different Subjects in the database, and the second Combobox needs to show all the different topics that are currently shown in the datagridview (So only the topics related to the currently filtered subject are shown)

Sorry if this is a little hard to understand, I'd be happy to follow up with any more information if needed.

Thanks in advance.
Sergey Alexandrovich Kryukov 18-Mar-13 15:45pm    
What did you try so far?

1 solution

You can implement the following solution
1. Populate both Subject and Topics tables
2. Add both tables to a DataSet
3. Add relationship between Subject and Topics (See the below link)
4. Populate Subject in one Combo
5. Populate Topics in another combo. Now when user select a subject, the topics combo will get filtered automatically.

The following link will tell you how to add relationships[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900