Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
using vsstudio 2010 (c#, windowsforms)..

tblcustomer..
[custno, name, age, gender, addr]

the sample code i make works fine but it only search through by [name]. i want to make a search|filter by the selected items in my combobox. items in my combobox is my column names of table.. TIA..

What I have tried:

this.tblcustomerBindingSource.Filter = "name like '%" + textBox1.Text + "%' ";
Posted
Updated 6-Apr-17 23:23pm
v2

1 solution

try like this

string column = comboBox1.Text;
           string text = textBox1.Text;
           string filter = string.Format("{0} like '%{1}%'", column, text);
           this.tblcustomerBindingSource.Filter = filter;

Note: Take care of the validations.
 
Share this answer
 
v2
Comments
akosisugar 7-Apr-17 5:31am    
perfect! tnx sir!
Karthik_Mahalingam 7-Apr-17 5:37am    
welcome

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