CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2010
    Posts
    2

    Help with creating a filter in a data grid!!

    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<QuarantineView> qvList = dgPortStatus.DataContext as List<QuarantineView>;
    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<QuarantineView> qvList = dgPortStatus.DataContext as List<QuarantineView>;
    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<QuarantineView> qvList)
    {


    }

  2. #2
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: Help with creating a filter in a data grid!!

    edit your post and add CODE tags... then we'll see what can be done
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  3. #3
    Join Date
    Dec 2010
    Posts
    2

    Re: Help with creating a filter in a data grid!!

    Sorry, It will not let me edit my post.

  4. #4
    Join Date
    Oct 2004
    Location
    Rocket City
    Posts
    220

    Re: Help with creating a filter in a data grid!!


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured