Results 1 to 19 of 19

Thread: Filter a Flexgrid

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    64

    Cool Filter a Flexgrid

    Does anyone know a nice way to filter a flexgrid?

    I have been searching the web and have found work around suggestions, - the best was probably setting the rowheight = 0 - but that would require looping through each row.

    In my case, I have an unbound flexgrid that includes a column that can equal one of two values. Is there a setting that can be used to make the grid show only the rows with one of these values?

    Thank you.

  2. #2

  3. #3
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Filter a Flexgrid

    Tony

    I'd say that RhinoBull has asked the key question.

    Implicit is the concept that if your data can be
    "prefiltered", then you'd populate the FG with only
    the desired "rows"

    Spoo

  4. #4
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Filter a Flexgrid

    Anthony,
    i think u r trying to show or hide column / row depends on value exist or not, as spoo told, try to populate as prefiltered, other wise u hav to set row height = 0 to hide.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    64

    Re: Filter a Flexgrid

    I have an unbound grid populated from various sources and want the user to be able to selectivly view all records, or only ones with value A or Value B (so the selection cannot be restricted).

  6. #6

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    64

    Re: Filter a Flexgrid

    I am populating the grid from a spreadsheet - containing Bank Transactions. The user will tick some of these transactions as reconciled. I have a combo box that holds three values - reconciled, unreconciled and All. When the user selects one of the values in the combo box, I want the grid to display all of the transactions that have the value selected - ie show all reconciled or all unreconciled or everything - depending on their selection.

    I realise that I could loop through the grid setting the row height to zero for any transaction that does not match the users selection, but was wondering if the grid had a property that would display only rows where column N = "Reconciled" etc to avoid the loop.

  8. #8
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Filter a Flexgrid

    I purposly asked you (few times) how you populate grid ans was hoping that you would get the idea...
    Anyway, rather than changing row height I would re-populate grid. You must have some produre that does it, don't you.
    You may pass an argument to that procedure (say: filterCriteria as String) and the possible values could be "reconciled", "unreconciled" or "all".
    Based on that argument value your procedure should "know" what to select from the source.

  9. #9

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    64

    Question Re: Filter a Flexgrid

    Sorry Rhino but I must be really thick or something.
    I just dont see how repopulating from the spreadsheet would help, when the values "Reconciled" etc have been entered on the grid, and therefore do not exist in the spreadsheet.

  10. #10
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Filter a Flexgrid

    Your original idea of looping thru the rows (which you are trying to avoid) is the simplest method of achieving what you want, and should only be a few lines of code.

  11. #11
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Filter a Flexgrid

    You could use 2 grids
    1.- Pass from spreadsheet to grid1
    2.- User tick some of these transactions as reconciled, then, pass this row to grid2 and remove from grid1

    JG

  12. #12
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Filter a Flexgrid

    Quote Originally Posted by Anthonynz View Post
    ...
    ... but was wondering if the grid had a property that would display only rows where column N = "Reconciled" etc to avoid the loop.
    Tony

    Short answer is no.
    FG's do not have such a property.

    Hence the jist of the several approaches that have been suggested:
    • Si - setting row height to 0 may be the quickest and easiest
    • Rhino, et al - put contents of Excel sheet into an array.
      The array will have all data.
      Then, after the user has "ticked" the reconciled ones and subsequently
      selects which ones should be displayed, clear the grid and repopulate
      it from the array accordingly.

    In either case, (setting row height or populating from array), do this:
    • first, set the Visible property to False.
    • then do your thing
    • finally, set Visible = True

    This may seem counter-intuitive, but it will significantly speed up
    the processing (and thus the "refresh") of the FG. No flicker will occur.

    Spoo

  13. #13

  14. #14

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    64

    Resolved Re: Filter a Flexgrid

    Ok thanks Guys.

    Spoo - Its nice to have a definitive answer - even though its a No.

    Jggtz - Interesting idea - using two grids I could make one visable and one not, (but I would have to maintain two grids).

    I think considering all options I will Loop and set Row Heights.

    Thanks all for your help

  15. #15
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Filter a Flexgrid

    Anthony, i tried ADO with excel as database, without looping, i hav attached as project, just check and feedback, while first time run it gives an error 'selected collating seq not supported by the OS' but it wont show after compiled, so dont wory abt it
    Attached Files Attached Files
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  16. #16

    Thread Starter
    Lively Member
    Join Date
    May 2010
    Posts
    64

    Resolved: Re: Filter a Flexgrid

    Hi Seenu - thats a cool bit of code - really clean.

    It does not help my current issue (cos the Reconciled flag is being set on the grid when the user clicks on a row) - but I can probably use that method elsewhere

    By the way - how do I mark a thread as Resolved - I have put Resolved in the Title of my reply - is that enough? Cheers.

  17. #17
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Filter a Flexgrid

    why dont u use the combo box to let the user to select category so u can use the fast fill method with out looping, just a suggestion to avoid loop.
    and u can use Thread tools above to mark thread as resolved.
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  18. #18

  19. #19
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Filter a Flexgrid

    Quote Originally Posted by RhinoBull View Post
    Seenu,

    that's the way to go - query source, populate recordset, use Clip to avoid looping...
    In fact all of the above is available via "ms flexgid tips & tricks" link in my signature.
    yes, i did see that link now
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


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