Search code examples
c#winformsinfragisticsultrawingrid

Is there a way to filter UltraGrids based on the value of 2 columns?


Say I have an Infragistic UltraGrid with columns Foo and Bar. Is it possible to filter the table so that only rows where Foo and Bar are not equal are displayed?

For instance, if I had this data:

Foo  Bar
--------
0.1  0.1
0.1  0.2
0.2  0.2

The filter would hide the first and the third row.


Solution

  • It is simplier than it seems and i am sure you do not have to create additional column or something:

    UltraGridColumn fooColumn = Grid.DisplayLayout.Bands[0].Columns["Foo"];
    UltraGridColumn barColumn = Grid.DisplayLayout.Bands[0].Columns["Bar"];
    ColumnFilter fooColumnFilter = fooColumn.Band.ColumnFilters[fooColumn];
    fooColumnFilter.ClearFilterConditions();
    fooColumnFilter.FilterConditions.Add(FilterComparisionOperator.NotEquals, barColumn);