gpt4 book ai didi

c# - datagridview 中多列的搜索栏

转载 作者:太空宇宙 更新时间:2023-11-03 20:10:02 24 4
gpt4 key购买 nike

我正在使用文本框来搜索数据 GridView 。但它只搜索一列。我也想用它来搜索其他列。我目前用于搜索栏的代码是:

private void autoZoeken_txt_TextChanged(object sender, EventArgs e)
{
DataView DV = new DataView(dbdataset);
DV.RowFilter = string.Format("kenteken LIKE '%{0}%'", autoZoeken_txt.Text);
autoView_dgv.DataSource = DV;
}

最佳答案

您只需修改代码以利用OR:

private void autoZoeken_txt_TextChanged(object sender, EventArgs e)
{
DataView DV = new DataView(dbdataset);
DV.RowFilter = string.Format(
"kenteken LIKE '%{0}%' OR field2 LIKE '%{0}%'", autoZoeken_txt.Text);
autoView_dgv.DataSource = DV;
}

等等。

关于c# - datagridview 中多列的搜索栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20612408/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com