troubleshooting Question

Use of rowfilter with option "all"

Avatar of Mark Bakelaar
Mark BakelaarFlag for Norway asked on
.NET ProgrammingVisual Basic.NET
4 Comments1 Solution236 ViewsLast Modified:
Hi Experts,
I have two comboboxes in which the user can select items used for a rowfilter. Both comboboxes have the option "all" in it. There are 4 options (all - all, all - specific, specific - all and specific - specific). I attached the code that works for the rowfilter.

However, I need to add to 2 additional comboboxes. The number of options now increases to 16, thus a lot of code with if statements. It there a way to make a single statement that recognizes the "all" option and does not use a filter in this case.

Hope somebody can prevent building a monstercode... thanks in advance, MB
Dim BookingView As DataView = Me.DataGridView1.DataSource
 
        If Me.ComboBox1.Text = "all" And Me.ComboBox2.Text = "all" Then
            BookingView.RowFilter = ""
        ElseIf Me.ComboBox1.Text = "all" Then
            BookingView.RowFilter = "Loadport LIKE '%" & Me.ComboBox2.Text & "%'"
        ElseIf Me.ComboBox2.Text = "all" Then
            BookingView.RowFilter = "Voyage LIKE '%" & Me.ComboBox1.Text & "%'"
        Else
            BookingView.RowFilter = "Voyage LIKE '%" & Me.ComboBox1.Text & "%' AND Loadport LIKE '%" & Me.ComboBox2.Text & "%'"
        End If
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros