I’m new to programming, and trying to develop a database application with C# 2010 Express using MS Access DB 2010.
I’ve DataGridView and Detail view generated thru wizard on the form. I’m filtering the data with TextChanged event of a textbox.
When I navigate records, datagridview also scrolls according to current record on Detail view, and vice versa.
After filtering applied and removed this navigation behavior does not work at all (i.e. datagridview does not scroll according to current record in detail view anymore).
Any help would be appreciated.
Thanks.
Here is the code I use for filtering data (FilterField comes from Tag properties of radio buttons):
DataView dv = new DataView(personel_csDataSet.Tables["tblData"]);
dv.RowFilter = FilterField + " like '%' + '" + tbFilter.Text + "' + '%' ";
this.tblDataDataGridView.DataSource = dv;
tblDataBindingSource.Filter = FilterField + " like '%' + '" + tbFilter.Text + "' + '%' ";
That’s because you set a different data source to the grid and the details view. If tblDataBindingSource is the data source of the detail view, assign it as a data source of the grid and don’t create another view:
this.tblDataDataGridView.DataSource = tblDataBindingSource;
tblDataBindingSource.Filter = FilterField + ” like ‘%’ + ‘” + tbFilter.Text + “‘ + ‘%’ “;
BTW, you don’t have to assign the data source exactly there. You can do it in the beginning and you don’t have to reassign it after applying a filter.