2 filters on Bindingsource in Vb

Asked

Viewed 113 times

1

I own a datagridview of employees and I can filter them through the name of each employee through this code:

FuncionariosBindingSource.Filter = "nome like'%" & TextBox1.Text & "%'"

In this same datagridview I have a column "year" that is marked the employee entry, I wonder if there is a way to filter the name and year of the employee. For example in textbox1 type "Joao" and in textbox2 (For the year) type 2015, there appeared only Joao 2015.

Someone could help me?

1 answer

1


Good morning Matthew, you will have to create another field to insert the year and in the event that makes the search you use the field of the year to filter. There is an example in the link below that is well explained.

http://www.macoratti.net/09/04/c_dtb1.htm

  • I understood more or less this link, my difficulty is to adapt, because the site that Voce passed is c# and I’m using basic look and I’m not able to fit this code. I tried so : FuncionariosBindingSource.Filter = "nome like '%" + TextBox1.Text + "%' AND ano = " + TextBox2.Text and it didn’t work out

  • 1

    Now I got it with that code here: FuncionariosBindingSource.Filter = "nome LIKE '%" + TextBox1.Text + "%' and ano LIKE '%" + TextBox2.Text + "%'" Thanks for the help!

  • The link was more like you had a real sense of how to do it... I’m glad you made it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.