Thanks
I will try that approach, but the code I have works if I only use a DataGridView and a BindingSource.
Trouble comes when I use a DataGridView BindingManager hooked up to a BindingSource
and get the data from an entity list.
The
code below is an edited extract from the class frmSearchGrid() which allows me
to search any DataGridView because the code generates the search parameter (strFilter)
dynamically.
//constructor
frmSearchGrid(
DataGridView _DataGrid, BindingSource _BS)
…..
SearchGrid
()
{
….
// cboColumn is a combo box that lists all the
visible columns in the DataGridView
String strFilter
= "[" + cboColumn.SelectedItem.ToString()
+ "]" + "
= " + "'" + txtSearch.Text.ToString()
+ "'";
_BS.Filter = strFilter;
if ( _DataGrid.Rows.Count ==
0)
{
// search item not found
_BS.RemoveFilter();
MsgBox.Show(" Search item not found ");
txtSearch.Focus();
return;
}
else
{
// search item found
this.Close();
return;
}
….
}
Edited by Tich - 05-Sep-2007 at 7:01am