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)
{
}
Suthish NairPosted Dec 9, 2010, 1:30 PM
var aa = from bb in qvList where qvList.Contains(your value) select bb
some good examples..
http://www.hookedonlinq.com/QueryExpressionSyntax.ashx
Bradley GeorgePosted Dec 8, 2010, 11:09 PM
Sam HobbsPosted Dec 8, 2010, 10:29 PM
Bradley GeorgePosted Dec 8, 2010, 9:19 PM
I cant quite figure out how to do it.
Sam HobbsPosted Dec 8, 2010, 9:12 PM