The following code demonstrates usage of RecordFilterChanging and RecordFilterChanged events.
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_RecordFilterChanging(ByVal sender As Object, ByVal e As RecordFilterChangingEventArgs)
' NewRecordFilter property returns the new filter criteria for the field.
Dim newFilter As RecordFilter = e.NewRecordFilter
Dim field As Field = newFilter.Field
' Print out the new filter conditions.
If newFilter.Conditions.Count > 0 Then
Debug.WriteLine("Record filter of " + field.Name + " field is being changed to " + newFilter.Conditions.ToolTip.ToString())
Else
Debug.WriteLine("Record filter of " & field.Name & " field is being cleared.")
End If
' You can cancel the the change by seeting Cancel property.
'e.Cancel = true;
End Sub
Private Sub Dp_RecordFilterChanged(ByVal sender As Object, ByVal e As RecordFilterChangedEventArgs)
' RecordFilter property returns the new filter criteria for the field.
Dim newFilter As RecordFilter = e.RecordFilter
Dim field As Field = newFilter.Field
' Print out the new filter conditions.
If newFilter.Conditions.Count > 0 Then
Debug.WriteLine("Record filter of " + field.Name + " field has been changed to " + newFilter.Conditions.ToolTip.ToString())
Else
Debug.WriteLine("Record filter of " & field.Name & " field has been cleared.")
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_RecordFilterChanging( object sender, RecordFilterChangingEventArgs e )
{
// NewRecordFilter property returns the new filter criteria for the field.
RecordFilter newFilter = e.NewRecordFilter;
Field field = newFilter.Field;
// Print out the new filter conditions.
if ( newFilter.Conditions.Count > 0 )
Debug.WriteLine( "Record filter of " + field.Name + " field is being changed to " + newFilter.Conditions.ToolTip.ToString( ) );
else
Debug.WriteLine( "Record filter of " + field.Name + " field is being cleared." );
// You can cancel the the change by seeting Cancel property.
//e.Cancel = true;
}
private void dp_RecordFilterChanged( object sender, RecordFilterChangedEventArgs e )
{
// RecordFilter property returns the new filter criteria for the field.
RecordFilter newFilter = e.RecordFilter;
Field field = newFilter.Field;
// Print out the new filter conditions.
if ( newFilter.Conditions.Count > 0 )
Debug.WriteLine( "Record filter of " + field.Name + " field has been changed to " + newFilter.Conditions.ToolTip.ToString( ) );
else
Debug.WriteLine( "Record filter of " + field.Name + " field has been cleared." );
}
The following XAML code hooks into RecordFilterChanging and RecordFilterChanged events and enables the record filtering functionality.
<igDP:XamDataGrid x:Name="_dp" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
RecordFilterChanging="dp_RecordFilterChanging"
RecordFilterChanged="dp_RecordFilterChanged"
>
<igDP:XamDataGrid.FieldSettings>
<!--Set AllowRecordFiltering to enable filter-record.-->
<igDP:FieldSettings AllowRecordFiltering="true" />
</igDP:XamDataGrid.FieldSettings>
</igDP:XamDataGrid>
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