Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
9364
Highlighting rows that satisfy a query clause
posted

Grid  has fields   A1  A2  A3   and A4.  Requirement is to highlight records that meet a dynamically changing selection criteria.

So, for example, if selection criteria is (A1 == 10 & A4 == 30), then all records that meet the criteria need to be highlighted.  Later, when the criteria changes to something completely different, the new set of record meeting that criteria are highlighted instead.

The idea is to show all records at all times but highlight only the ones that meet the current criteria .

- Anything built-in in Grid to help me with this

- If not, is my only option to just iterate over the entire row collection, examine each record to meet the new criteria and set the highlighting?

Thanks!

Parents
  • 469350
    Offline posted

    There are a couple of ways you can do this. Neither of thm require you to loop over all the rows in the grid. :) 

    One approach would be to use row filtering. Normally, filtering on the grid hides the filtered out rows and only shows the rows that meet the filter criteria. But you can change this so that it simply applies an appearance to the row. What you would do is set RowFilterAction on the Override to ApearancesOnly. Then you can set the FilteredInRowAppearance. And apply filters to the grid using the ColumnFilters collection on the band - or even let the user filter the data however they want by setting AllowRowFiltering. 

    Another option would be to simply use the InitializeRow event of the grid. You can examine the row and see if it meets your current filter criteria and then either apply an appearance to the row or clear it. If you want to take this route, I recommend that you check out the WinGrid Performance Guide for some advice on the most efficient way to do it. 

    Oh... I almost forgot. If you go with the second method, you will need to call grid.Rows.Refresh(FireInitializeRow) whenever your criteria changes so the event will fire again.

Reply Children