vb.net datagridview 搜索

2024-11-15 21:12:20
推荐回答(2个)
回答1:

private void button1_Click(object sender, EventArgs e)
{
    string colname = "你的列名";
    string txt = textBox1.Text.Trim();
    DataView dv = (DataView)dataGridView1.DataSource;
    dv.RowFilter = string.Format("{0} like '%{1}%'", colname, txt);
    dataGridView1.DataSource = dv;
}

回答2:

它内部绑定是一个DS.Tables(0).DefaultView

DS.Tables(0).DefaultView.RowFilter = '某一列的字段的值'