Version

RecordFilterDropDownPopulating Event

Raised before the filter drop-down is populated by the data presenter, giving you a chance to populate the filter drop-down with your own items.
Syntax
'Declaration
 
Public Event RecordFilterDropDownPopulating As EventHandler(Of RecordFilterDropDownPopulatingEventArgs)
public event EventHandler<RecordFilterDropDownPopulatingEventArgs> RecordFilterDropDownPopulating
Event Data

The event handler receives an argument of type RecordFilterDropDownPopulatingEventArgs containing data related to this event. The following RecordFilterDropDownPopulatingEventArgs properties provide information specific to this event.

PropertyDescription
AsynchLoadDuration Specifies the maximum number of milliseconds to load unique values before stopping to wait for another AsynchLoadInterval.
AsynchLoadInterval Specifies the timer interval used to trigger asynchronous load processing.
AsynchLoadThreshhold Specifies the maximum number of milliseconds to use to load unique values before continuing the loading process asynchronously.
DropDownItems Returns the items that will be displayed in the filter drop-down. You can modify the list to add new entries or remove existing entries from the filter drop-down.
Field Returns the associated Field (read-only).
Handled (Inherited from System.Windows.RoutedEventArgs)Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route.
IncludeUniqueValues Specifies whether the data presenter should include unique field values from the data source in the filter drop-down list.
ItemsType Returns an enumeration indicating whether the DropDownItems or MenuItems are used to populate the drop down.
MenuItems Returns the menu items that will be displayed in the filter drop-down. You can modify the list to add new entries or remove existing entries from the filter drop-down.
OriginalSource (Inherited from System.Windows.RoutedEventArgs)Gets the original reporting source as determined by pure hit testing, before any possible System.Windows.RoutedEventArgs.Source adjustment by a parent class.
RaisedForCustomFilterSelectionControl Returns true if this event is raised when the user drops down the filter drop-down in the custom filter selection control.
RecordManager Returns the associated RecordManager (read-only).
RoutedEvent (Inherited from System.Windows.RoutedEventArgs)Gets or sets the System.Windows.RoutedEventArgs.RoutedEvent associated with this System.Windows.RoutedEventArgs instance.
Source (Inherited from System.Windows.RoutedEventArgs)Gets or sets a reference to the object that raised the event.
Remarks

RecordFilterDropDownPopulating is raised whenever the user drops down the filter drop-down in a filter cell or via the filter icon of a field label (see FieldLayoutSettings.FilterUIType). You can manipulate the list of items that will be displayed in the filter drop-down using the DropDownItems property of the event args.

Example
The following code populates the operand drop-down of string fields with custom items that filter using regular expression.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Windows
Imports Infragistics.Windows.Controls
Imports Infragistics.Windows.Editors
Imports Infragistics.Windows.DataPresenter
Imports Infragistics.Windows.DataPresenter.Events

    Private Sub Dp_RecordFilterDropDownPopulating(ByVal sender As Object, ByVal e As RecordFilterDropDownPopulatingEventArgs)
        If e.Field.EditAsTypeResolved Is GetType(String) Then
            ' At this point, e.DropDownItems will be pre-populated with special operands, like
            ' (Custom), (Blanks), (NonBlanks) etc... You can remove them if you don't want to
            ' display those options.
            ' 
            ' Remove all but (All) and (Custom) items from the drop-down.
            ' 
            Dim i As Integer
            For i = e.DropDownItems.Count - 1 To 0 Step -1
                ' Remove all but (All) and (Custom) items from the list.
                ' 
                If Not e.DropDownItems(i).DisplayText.StartsWith("(All)") _
                  AndAlso Not e.DropDownItems(i).DisplayText.StartsWith("(Custom)") Then
                    e.DropDownItems.RemoveAt(i)
                End If
            Next


            ' After this event is raised, data presenter will populate the drop-down with
            ' field values. If you don't want to display field values in the filter drop-down
            ' then set IncludeUniqueValues to false, which will prevent the data presenter
            ' from adding field values to the drop-down.
            ' 
            e.IncludeUniqueValues = False

            ' Add custom items. Items can be ICondition derived class (here we are using built-in
            ' ComparisonCondition), or a SpecialFilterBase derived class, or a ICommand (which
            ' lets you to take an action, like show a dialog). You can even implement your own 
            ' ICondition to provide completely custom logic.
            ' 
            Dim item As FilterDropDownItem
            item = New FilterDropDownItem(New ComparisonCondition(ComparisonOperator.Match, "^[A-F]"), "A-F")
            e.DropDownItems.Add(item)

            item = New FilterDropDownItem(New ComparisonCondition(ComparisonOperator.Match, "^[G-K]"), "G-K")
            e.DropDownItems.Add(item)

            item = New FilterDropDownItem(New ComparisonCondition(ComparisonOperator.Match, "^[L-P]"), "L-P")
            e.DropDownItems.Add(item)

            item = New FilterDropDownItem(New ComparisonCondition(ComparisonOperator.Match, "^[Q-Z]"), "Q-Z")
            e.DropDownItems.Add(item)
        End If
    End Sub
using Infragistics.Windows;
using Infragistics.Windows.Controls;
using Infragistics.Windows.Editors;
using Infragistics.Windows.DataPresenter;
using Infragistics.Windows.DataPresenter.Events;

		private void dp_RecordFilterDropDownPopulating( object sender, RecordFilterDropDownPopulatingEventArgs e )
		{
			if ( e.Field.EditAsTypeResolved == typeof( string ) )
			{
				// At this point, e.DropDownItems will be pre-populated with special operands, like
				// (Custom), (Blanks), (NonBlanks) etc... You can remove them if you don't want to
				// display those options.
				// 
				// Remove all but (All) and (Custom) items from the drop-down.
				// 
				for ( int i = e.DropDownItems.Count - 1; i >= 0; i-- )
				{
					// Remove all but (All) and (Custom) items from the list.
					// 
					if ( ! e.DropDownItems[i].DisplayText.StartsWith( "(All)" )
						&& ! e.DropDownItems[i].DisplayText.StartsWith( "(Custom)" ) )
					{
						e.DropDownItems.RemoveAt( i );
					}
				}

				// After this event is raised, data presenter will populate the drop-down with
				// field values. If you don't want to display field values in the filter drop-down
				// then set IncludeUniqueValues to false, which will prevent the data presenter
				// from adding field values to the drop-down.
				// 
				e.IncludeUniqueValues = false;

				// Add custom items. Items can be ICondition derived class (here we are using built-in
				// ComparisonCondition), or a SpecialFilterBase derived class, or a ICommand (which
				// lets you to take an action, like show a dialog). You can even implement your own 
				// ICondition to provide completely custom logic.
				// 
				FilterDropDownItem item;
				item = new FilterDropDownItem( new ComparisonCondition( ComparisonOperator.Match, "^[A-F]" ), "A-F" );
				e.DropDownItems.Add( item );

				item = new FilterDropDownItem( new ComparisonCondition( ComparisonOperator.Match, "^[G-K]" ), "G-K" );
				e.DropDownItems.Add( item );

				item = new FilterDropDownItem( new ComparisonCondition( ComparisonOperator.Match, "^[L-P]" ), "L-P" );
				e.DropDownItems.Add( item );

				item = new FilterDropDownItem( new ComparisonCondition( ComparisonOperator.Match, "^[Q-Z]" ), "Q-Z" );
				e.DropDownItems.Add( item );
			}
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also