DataFilter for WinForms | ComponentOne
C1.Win.DataFilter.4.5.2 Assembly / C1.DataFilter Namespace / FilterAutoGeneratingEventArgs Class
Members

In This Topic
    FilterAutoGeneratingEventArgs Class
    In This Topic
    Provides data for the FilterAutoGenerating event of a C1DataFilter control.
    Object Model
    FilterAutoGeneratingEventArgs Class
    Syntax
    'Declaration
     
    Public Class FilterAutoGeneratingEventArgs 
       Inherits System.ComponentModel.CancelEventArgs
    public class FilterAutoGeneratingEventArgs : System.ComponentModel.CancelEventArgs 
    Remarks

    This class provides data for the FilterAutoGenerating event of the C1DataFilter control. The FilterAutoGenerating event gets fired before a filter is added to the FilterCollection. This event allows you to modify the automatically generated filters or to cancel the generation of filters. The listing below provides the details about the event data.

    • The Property property gets the data item property for which the current filter is being generated.
    • The currently generating filter can be accessed using the Filter property.
    • The event can be cancelled using the Cancel property, when there is no need to generate filters for specific data fields.
    Example

    private void C1DataFilter1_FilterAutoGenerating(object sender, C1.DataFilter.FilterAutoGeneratingEventArgs e)

    {

     switch (e.Property.Name)

     {

      //Set the checklist items for Brand filter
     case "Brand":

      var brandFilter = (C1.Win.DataFilter.ChecklistFilter) e.Filter;

      brandFilter.ItemsSource = _carsTable;

      brandFilter.ValueMemberPath = "Brand";

      brandFilter.SelectAll();

      break;

      //Set the checklist items for Category filter
     case "Category":

      var categoryFilter = (C1.Win.DataFilter.ChecklistFilter) e.Filter;

      categoryFilter.ItemsSource = _carsTable;

      categoryFilter.ValueMemberPath = "Category";

      categoryFilter.SelectAll();

      break;

      //Set the minimum/maximum value for the Price filter
     case "Price":

      var priceFilter = (C1.Win.DataFilter.RangeFilter) e.Filter;

      priceFilter.Maximum = _carsTable.AsEnumerable().Max(x = >x.Field < double > ("Price"));

      priceFilter.Minimum = _carsTable.AsEnumerable().Min(x = >x.Field < double > ("Price"));

      priceFilter.Increment = 1000;

      priceFilter.Digits = 0;

      break;

      //Cancels the creation of all other filters
     default:

      e.Cancel = true;

      break;

     }

    }

    Inheritance Hierarchy

    System.Object
       System.EventArgs
          System.ComponentModel.CancelEventArgs
             C1.DataFilter.FilterAutoGeneratingEventArgs

    See Also