I want to create a filter to filter text in a datagrid as i type in a text box. I have two text boxes, one to filter in text that i type and one to filter out text that i type. I want the data grid to update as i type into either one of the textboxes. Here is some of my code:
private void txtFilterIn_TextChanged(object sender, TextChangedEventArgs e)
{
DataView dv = dgPortStatus.DataContext as DataView;
if (dv != null)
{
if (dv.Table.TableName.ToUpper() == "PORTSTATUS")
{
FilterDataGrid(txtFilterIn.Text, txtFilterOut.Text, _dicPortStatus[cmbGroups.SelectedItem.ToString()]);
}
}
List qvList = dgPortStatus.DataContext as List;
if (qvList != null)
{
//Filter on quarantine manager
FilterQuarantineViewList(qvList);
}
}
private void btnFilterInClear_Click(object sender, RoutedEventArgs e)
{
txtFilterIn.Clear();
}
private void txtFilterOut_TextChanged(object sender, TextChangedEventArgs e)
{
DataView dv = dgPortStatus.DataContext as DataView;
if (dv != null)
{
if (dv.Table.TableName.ToUpper() == "PORTSTATUS")
{
FilterDataGrid(txtFilterIn.Text, txtFilterOut.Text, _dicPortStatus[cmbGroups.SelectedItem.ToString()]);
}
}
List qvList = dgPortStatus.DataContext as List;
if (qvList != null)
{
//Filter on Quarantine Manager
FilterQuarantineViewList(qvList);
}
}
private void btnFilterOutClear_Click(object sender, RoutedEventArgs e)
{
txtFilterOut.Clear();
}
And this method is where my filter needs to go:
private void FilterQuarantineViewList(List qvList)
{
}

Sam HobbsRank #108 · 20.5K reputationPosted Dec 8, 2010, 4:12 PM EST
Bradley George13 reputationPosted Dec 8, 2010, 4:19 PM EST
I cant quite figure out how to do it.
Sam HobbsRank #108 · 20.5K reputationPosted Dec 8, 2010, 5:29 PM EST
Bradley George13 reputationPosted Dec 8, 2010, 6:09 PM EST
Suthish NairRank #92 · 22.8K reputationPosted Dec 9, 2010, 8:30 AM EST
var aa = from bb in qvList where qvList.Contains(your value) select bb
some good examples..
http://www.hookedonlinq.com/QueryExpressionSyntax.ashx