We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Filtering Data in a datagridview using visual studio 2005 (vb.net) help for a newbie

Medium Priority
Last Modified: 2012-05-06
I am below a novice at this so the easier the explaination and steps the better. I am creating a vb .net form using visual studio 2005. I created a datagridview (datagridview1) that attaches to my erp database as readonly (ms sql2000). The grid contains a query (code not shown) that populates information correctly. From there I created a combo box that will filter the data in the grid (see code). The problem that I have is when I filter the data, it will show me all the records in the grid for that PO and what I want to do is be able to filter records based on multiple criteria. As an example I select the PO in my combobox. It returns all records based that PO. Now what would like to do is create two text boxes (unbound I'm guessing) and filter the grid further based on a date in my grid called Receiver_Date. So I would select a PO from my first combbox(record filter) then put in the through and from dates. The other issue I am have is currently in my Receiver_Date field on the grid the returned records currently show up as date time (ex: 12/29/2008 11:40 am) I just want the date to show up with out the time and cannot find where to do this. Sorry if I rambled. I hope my explaination makes sense. Also please let me know if there is anything else I need to watch out for.
'Filter Data by PO
If ComboBox1.SelectedIndex > 0 Then
            Me.POIBindingSource.Filter = "PO_Name = '" & ComboBox1.SelectedValue.ToString & "'"
            Me.POIBindingSource.Sort = "PO_Name, Item_Name, Purchase_Order_ID"
        End If
    End Sub

Open in new window

Watch Question

Most Valuable Expert 2012
Top Expert 2014
You have to play with this line

Me.POIBindingSource.Filter = "PO_Name = '" & ComboBox1.SelectedValue.ToString & "'"

If you need to filter on date then
Me.POIBindingSource.Filter = "PO_Name = '" & ComboBox1.SelectedValue.ToString & "' AND PO_Date>'" & txtdate.value & "'"

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.