We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How do I show the top-so-many or bottom-so-many records in a filter?

The QueryRecordMeetsFilterCriteria event has to be handled to get this behavior. A Hashtable is used to handle the values that are to be filtered at the top and bottom. The following sample displays the first 2 and last 2 records in a filter. The Hashtable is filled by using the user defined function, SetPositionFilter().

To perform a filter that restricts the filtered set to a certain number of elements, you have to filter twice. In the first pass, you get the total set of records that satisfies the filter. Then these records are numbered by using an unbound column populated indirectly with the SetPositionFilter method. Once the unbound column is populated with a position index value, you can then apply a second filter to select the first so-many or last so-many records.

C#

 

VB

 

Figure 1: Top and bottom 2 records value set as true on filtering first time

Figure 2: Top and bottom 2 values filtered on second time filtering applied to the same value

Sample Links

UnboundFilter-C#

UnboundFilter-VB

 

Article ID: Published Date: Last Revised Date: Platform: Control:
591 04/30/2011 03/10/2015 Windows Forms GridGroupingControl
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.