Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi friends!
I want to search with two textbox in datagridview. vb.net
In my datagridview1 have:

_________________________________________________
|NUMBER_RECEIPT | DESCRIPTIONS | PRICE |
| 1 | Usb 8gb | 7$ |
| 1 | Usb 16gb | 12$ |
| 1 | Usb 32gb | 20$ |
| 2 | Usb 64gb | 35$ |
_________________________________________________

In textbox1 I want to search "NUMBER_RECEIPT" and textbox2 "DESCRIPTION"
FIRST TIME: If search in textbox1: "1" want to show:

_________________________________________________
NUMBER_RECEIPT | DESCRIPTIONS | PRICE |
| 1 | Usb 8gb | 7$ |
| 1 | Usb 16gb | 12$ |
| 1 | Usb 32gb | 20$ |
_________________________________________________

SECOND TIME: And after search in textbox1, I want to search in textbox2: "Usb 8"
I want to show:

_________________________________________________
NUMBER_RECEIPT | DESCRIPTIONS | PRICE |
| 1 | Usb 8gb | 7$ |
_________________________________________________

What I have tried:

I tried to find in internet.
I found some codes but for me does not work properly, for example:

VB
BindingSource7.Filter = "[NUMBER_RECEIPT] LIKE '" & TextBox1.Text & "%'" Or
BindingSource7.Filter = "[DESCRIPTIONS] LIKE '" & TextBox2.Text & "%'"


Please can you help me for this ?
THANK YOU VERY MUCH :)
Posted
Updated 21-Sep-17 6:18am
v6

1 solution

You need to combine the two conditions into a single filter. Something like this should work:
VB.NET
BindingSource7.Filter = "[NUMBER_RECEIPT] LIKE '" & TextBox1.Text & "%' And [DESCRIPTIONS] LIKE '" & TextBox2.Text & "%'"
 
Share this answer
 
Comments
ionMEMBER 21-Sep-17 12:34pm    
Yesssss its work. thank you very much ! :D

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