wpf-devexpress-dot-xpf-dot-editors-dot-lookupeditbase-8b672964.md
Allows you to customize the filter applied by LookUpEdit or ComboBoxEdit (for example, to filter data by an additional/another column).
Namespace : DevExpress.Xpf.Editors
Assembly : DevExpress.Xpf.Core.v25.2.dll
NuGet Package : DevExpress.Wpf.Core
public event EventHandler<SubstituteDisplayFilterEventArgs> SubstituteDisplayFilter
Public Event SubstituteDisplayFilter As EventHandler(Of SubstituteDisplayFilterEventArgs)
The SubstituteDisplayFilter event's data class is DevExpress.Xpf.Editors.Helpers.SubstituteDisplayFilterEventArgs.
In the code sample below, an editor filters items by FirstName with the following configuration:
<dxg:LookUpEdit DisplayMember="FirstName" .../>
public class Person {
public string FirstName { get; set; }
public string LastName { get; set; }
}
Public Class Person
Public Property FirstName As String
Public Property LastName As String
End Class
To filter items by both FirstName and LastName , add a corresponding condition in the SubstituteDisplayFilter event handler:
View Example: Filter the LookUpEdit by Multiple Columns
void SubstituteDisplayFilter(object sender, SubstituteDisplayFilterEventArgs e) {
if (string.IsNullOrEmpty(e.DisplayText))
return;
var extraFilter = CriteriaOperator.Parse("StartsWith(LastName,?)", e.DisplayText);
e.DisplayFilter = new GroupOperator(GroupOperatorType.Or, extraFilter, e.DisplayFilter);
e.Handled = true;
}
Private Sub SubstituteDisplayFilter(ByVal sender As Object, ByVal e As SubstituteDisplayFilterEventArgs)
If String.IsNullOrEmpty(e.DisplayText) Then Return
Dim extraFilter = CriteriaOperator.Parse("StartsWith(LastName,?)", e.DisplayText)
e.DisplayFilter = New GroupOperator(GroupOperatorType.[Or], extraFilter, e.DisplayFilter)
e.Handled = True
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SubstituteDisplayFilter event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
wpf-lookupedit-filter-by-multiple-columns/CS/MainWindow.xaml#L16
FilterCondition="Contains"
SubstituteDisplayFilter="lookUpEdit_SubstituteDisplayFilter">
<dxg:LookUpEdit.PopupContentTemplate>
wpf-lookupedit-filter-by-multiple-columns/CS/obj/Debug/net8.0-windows/MainWindow.g.cs#L91
#line 16 "..\..\..\MainWindow.xaml"
this.lookUpEdit.SubstituteDisplayFilter += new System.EventHandler<DevExpress.Xpf.Editors.Helpers.SubstituteDisplayFilterEventArgs>(this.lookUpEdit_SubstituteDisplayFilter);
wpf-lookupedit-filter-by-multiple-columns/VB/obj.NetFX/x86/Debug/MainWindow.g.vb#L90
#ExternalSource("..\..\..\MainWindow.xaml",16)
AddHandler Me.lookUpEdit.SubstituteDisplayFilter, New System.EventHandler(Of DevExpress.Xpf.Editors.Helpers.SubstituteDisplayFilterEventArgs)(AddressOf Me.lookUpEdit_SubstituteDisplayFilter)
See Also