How can I run foreach loop into filtered row in Ultra Grid?

626 Views Asked by At

How I can run for loop only filtered rows into UltraGrid? Suppose I've a Ultra grid about 1000 rows. But I need only run loop for 5 rows which I shall get by filtering

foreach (UltraGridRow row in grdMerchandiserToBuyer.Rows)
{
}

This code fetch all rows, but I want only filtered Rows into this Grid

Please help me if anyone know that Thanks

2

There are 2 best solutions below

0
jeroenh On

The UltraGrid.Rows property is of type RowsCollection, which has a method GetFilteredInNonGroupByRows. You should be able to do something like this:

foreach (UltraGridRow row in grdMerchaniserToBuyer.Rows.GetFilteredInNonGroupByRows())
{
   // your code here
}

https://www.infragistics.com/help/winforms/infragistics.win.ultrawingrid~infragistics.win.ultrawingrid.rowscollection~getfilteredinnongroupbyrows

2
Jackdaw On

If you have more than 5 filtered rows, but it's required to get only first five:

foreach (UltraGridRow row in grdMerchandiserToBuyer.Rows.GetFilteredInNonGroupByRows().Take(5))
{
    ...
}