Filter with flexgrid

Posted by: levanduyet on 9 August 2022, 11:28 am EST

    • Post Options:
    • Link

    Posted 9 August 2022, 11:28 am EST - Updated 3 October 2022, 10:18 pm EST

    Hi,

    I have a flexgird that show the table.

    I have 2 textbox, one for item code, one for description.

    I want that when i enter the text into textbox1 or textbox2 the flexgrid will auto filter be the value that I have entered to 2 textbox.

  • Posted 10 August 2022, 3:48 am EST

    Hi,

    you would have to do this yourself: loop over all rows and set visibility based on the filter.

    Here is a sample code snippet:

    
    private void FilterGrid (string text)
    {
      for (int row = this.c1FlexGrid.Rows.Fixed; row < this.c1FlexGrid.Rows.Count; row++)
      {
        //Get data of col "ItemCode"
        string itemcode = (string) this.c1FlexGrid[row, 2];
        string itemdescription = (string) this.c1FlexGrid[row, 3];
    
        this.c1FlexGrid.Rows[row].Visible = itemcode.Contains(text) || itemdescription.Contains(text);
      }
    }
    
    

    Hope this helps

    Wolfgang

  • Posted 10 August 2022, 5:21 am EST

    Hi,

    If you want to filter out the rows on the basis of searching the typed values in the textbox, you will need to do it manually by setting the Visible property of the non-matching rows to false (similar to what @Wolfgang suggested).

    If you want to filter out the rows on the basis of the fixed/specific values in your columns, you can use the Filter property of your required columns to assign a Value Filter to them. Kindly refer to the attached sample showing the same.

    FlexGridFilter.zip

    PS: Thanks for the suggestion, @Wolfgang!

    Best Regards,

    Kartik

  • Posted 11 June 2023, 2:48 am EST

    Thanks,

    Duyet Le

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels