Version

IncludeUniqueValues Property

Specifies whether the data presenter should include unique field values from the data source in the filter drop-down list.
Syntax
'Declaration
 
Public Property IncludeUniqueValues As Boolean
public bool IncludeUniqueValues {get; set;}
Remarks

You can set this property to false to prevent the data presenter from including field values in the filter drop-down list.

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