hello,
I want to know how to search in datagridview and only BindingSource, I want when the user starts to enter a word in a TextBox the result shows how to dynamically ing the datagridview!
I tried it but nothing happens!
private void textBox_search_word_TextChanged(object sender, EventArgs e)
{
if (textBox_search_word.Text == string.Empty)
{
MyBindingSource.RemoveFilter();
}
else
{
MyBindingSource.Filter = string.Format("Name LIKE '*{0}*'", textBox_search_word.Text);
MydataGridView.DataSource = MyBindingSource;
}
}
Thank you in advance
Loading
VulpesPosted Aug 9, 2013, 12:54 PM
http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.filter.aspx
If your BindingSource is just a collection of objects, then it probably won't work so you'd need to convert it to a DataTable first.
Abhineet SrivastavaPosted Aug 9, 2013, 11:57 AM
dgvStagiaires,Databind() after Datasource.
danyPosted Aug 9, 2013, 11:44 AM
VulpesPosted Aug 9, 2013, 5:48 AM
I assume that 'Nom' is in fact a valid column name and that leading/trailing spaces or case sensitivity (turned off by default) are not potential issues.
If you have a large number of rows in the data source, then response speed could be a problem as the DGV is being rebound (and hence redrawn) as each character is typed.
However, you should be able to remove this line:
dgvStagiaires.DataSource = bsStagiaires;
because just changing the Filter property should be enough to cause the DGV to redraw.