FlexGrid for WinForms | ComponentOne
C1.Win.C1FlexGrid Namespace / Column Class / AllowFiltering Property
Example

In This Topic
    AllowFiltering Property (Column)
    In This Topic
    Gets or sets this type of filter to use for this column.
    Syntax
    'Declaration
     
    
    Public Property AllowFiltering As AllowFiltering
    public AllowFiltering AllowFiltering {get; set;}
    Remarks

    The grid has an C1FlexGridBase.AllowFiltering property that determines whether columns can be filtered by the user. If that property is set to true, then filters are created automatically for each column based on the setting of the column's AllowFiltering property.

    The grid provides condition and value filters. Condition filters allow users to specify conditions such as 'value > 10'. Value filters allow users to select values that should be displayed from a list of values present in the data source. All filters can be customized in code as shown in the examples below.

    Example
    The code below customizes the filters for two columns. The "ShipRegion" column is initialized to show only two states, AK and CA. The "UnitPrice" column is initialized to show only items with unit price greater than $30. After the column filters have been initialized, the code calls the C1FlexGridBase.ApplyFilters method to apply the filters.
    // initialize "ShipRegion" column filter to show only two values: "AK" and "CA"
    var col = _flex.Cols["ShipRegion"];
    col.AllowFiltering = AllowFiltering.ByValue;
    var vf = col.Filter as ValueFilter;
    vf.ShowValues = new object[] { "AK", "CA" };
                
    // initialize "UnitPrice" column filter to show only values greater than $30
    col = _flex.Cols["UnitPrice"];
    col.AllowFiltering = AllowFiltering.ByCondition;
    var cf = col.Filter as ConditionFilter;
    cf.Condition1.Operator = ConditionOperator.GreaterThan;
    cf.Condition1.Parameter = 30;
                
    // apply both column filters to the data
    _flex.ApplyFilters();
    See Also