Hide filters programmatically using C#.

I am trying to create a custom FilterScheme using some predefined tables and columns using this code:

foreach (FilterCollection filterCollection in filteringScheme)
{
    if (IncludeTable(filterCollection.DataTableReference.Name))
    {
        foreach(Filter filter in filterCollection)
        {
            if (!IncludeColumn(filterCollection.DataTableReference.Name, filter.Name))
            {
                filterCollection.Remove(filter);
            }
        }
    }
    else
    {
        filteringScheme.Remove(filterCollection);
    }
}

The tables are being removed as expected (FilteringScheme.Remove works fine), but the problem is that filterCollection.Remove(filter) is not removing the filter from the filterCollection.

(1) Answer

Login