I am writing a program that uses a text box that the user can type into in order to search a data set of "staff".
The data from the "Staf" table is displayed in the data grid but i want the data grid to update as the user types into the search text box.
I can't figure it out i'm sure its simple and easy to solve but i need help please.
Thanks in advance!
You have to handle text changed event of the filter textbox (assuming that your datagrdview is databound):
private void textBoxFilter_TextChanged(object sender, EventArgs e)
{
//Replace your field here
(dataGridView.DataSource as DataTable).DefaultView.RowFilter = string.Format("Field = '{0}'", textBoxFilter.Text);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.