更新时间:2023-11-23 11:04:52
我有一个用于在特定列中进行搜索的文本框,但现在我必须修改此代码以在搜索开始时添加始终为0000,例如:
I需要的是,如果我在文本框中写了00001234,它会在该列上找到1234。我列上的所有数字都有4位数字,但我用来查找的条形码有8位数,因为在搜索中我需要添加4个ceros。
I have a textbox for make searchs in a specific column, but now i have to modify This code to add always 0000 at the start of the search for example:
I need that, If i wrote 00001234 in the textbox it would find 1234 on that column. All the numbers on my column has 4 digits, but the bar code i use to find has 8 digits becouse of that , in the search i need to add four ceros.
try
try
BindingSource bs = new BindingSource();
bs.DataSource = dataGrid1.DataSource;
string keyword = "0000" + txtSearch.Text.Trim();
bs.Filter = "BARCODE like '%" + keyword + "%'";
dataGrid1.DataSource = bs;