dataGridView中的动态搜索 [英] dynamic Search in dataGridView

查看:60
本文介绍了dataGridView中的动态搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友
我的表单中有很多行的DataGridView.
我想用textBox搜索DataGridView中的字符串.因此,当用户在textBox中键入名称时,通过在textBox上输入字符串,它会立即显示在datagridview上.
我的意思是动态搜索.
请帮忙.

Hello friends
i have a DataGridView in my form with many rows.
i want to search a string in DataGridView with a textBox.so when user type a name in textBox,immediately it will be shown on datagridview by entering string on textBox.
I mean Dynamic Search.
please help.

推荐答案

使用BindingSource.Filter:

Use BindingSource.Filter:

public void textBox1_TextChanged(object sender, EventArgs e)
{
    this.BindingSource.Filter = string.Format("Column_Name Like '%{0}%'", this.textBox1.Text);
}


这篇关于dataGridView中的动态搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆