RadControls for WinForms

There are two events that are raised when the data in the RadGridView is filtered. The first one is the FilterChanging event and it is raised before the data is filtered. The second one is the FilterChanged event which is raised after the data is filtered.

Copy[C#]
radGridView1.FilterChanging += new Telerik.WinControls.UI.GridViewCollectionChangingEventHandler(radGridView1_FilterChanging);
radGridView1.FilterChanged += new Telerik.WinControls.UI.GridViewCollectionChangedEventHandler(radGridView1_FilterChanged);
Copy[C#]
void radGridView1_FilterChanged(object sender, Telerik.WinControls.UI.GridViewCollectionChangedEventArgs e)
{

}

void radGridView1_FilterChanging(object sender, Telerik.WinControls.UI.GridViewCollectionChangingEventArgs e)
{

}
Copy[VB.NET]
Private Sub RadGridView1_FilterChanging(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCollectionChangingEventArgs) Handles RadGridView1.FilterChanging

End Sub

Private Sub RadGridView1_FilterChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCollectionChangedEventArgs) Handles RadGridView1.FilterChanged

End Sub

From the event arguments of both events you can access the following data:

  • Action – an enumeration with values: Add, Remove, ItemChanged and Reset. The Action property notifies if a FilterDescriptor is added, removed, modified or the FilterDescriptors collection is cleared.
  • NewItems - List of added, edited or removed FilterDescriptors. For each FilterDescriptor you can get its PropertyName, Operator, Value and Expression.

You are also able to cancel the filtering operation by setting the Cancel property to True.

Copy[C#]
void radGridView1_FilterChanging1(object sender, Telerik.WinControls.UI.GridViewCollectionChangingEventArgs e)
{
    e.Cancel = true;
}
Copy[VB.NET]
Private Sub RadGridView1_FilterChanging1(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCollectionChangingEventArgs) Handles RadGridView1.FilterChanging
    e.Cancel = True
End Sub

Since the FilterDescriptors collection implements the INotifyCollectionChanged interface, you can use its CollectionChanged event:

Copy[C#]
this.radGridView1.FilterDescriptors.CollectionChanged += new Telerik.WinControls.Data.NotifyCollectionChangedEventHandler(FilterDescriptors_CollectionChanged);
Copy[C#]
void FilterDescriptors_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
{

}
Copy[VB.NET]
AddHandler Me.RadGridView1.FilterDescriptors.CollectionChanged, AddressOf FilterDescriptors_CollectionChanged
Copy[VB.NET]
Private Sub FilterDescriptors_CollectionChanged(ByVal sender As Object, ByVal e As Telerik.WinControls.Data.NotifyCollectionChangedEventArgs)
    Throw New NotImplementedException
End Sub

The arguments of this event provide the same data as the FilterChanged event.