Home Forums WinForms controls Xceed Grid for WinForms How to return filtered grid rows only? Reply To: How to return filtered grid rows only?

User (Old forums)
Post count: 23064

Thanks for the info – much appreciated.

Your code looks good and I would have thought that it would work.

However after trying it I discovered that the .Visible property remains true even for
those rows that are not displayed (at least in Grid controlo v2.1 it does), which seems
strange to me and is surely a bug. How can the .Visble property be true if the row is not
actually visible?

I have discovered a workaround that relies on the .Key property. I noticed (while stepping
through in Debug mode) that the .Key property will be true for the filtered group of rows
displayed in the grid, while it will be false for the other group (the remaining rows that
are not part of the filtered group).

With that in mind I devised this: (Note: the index of the filtered group is not always at index=0 !!)

int grp_index=0;
for(int j=0; j<gridControl1.Groups.Count; j++)
if((bool)gridControl1.Groups[j].Key == true)
grp_index = j;

//now use grp_index to get at the filtered group only…
foreach(Xceed.Grid.DataRow dataRow in this.gridControl1.Groups[grp_index].GetSortedDataRows(true))
// do something with dataRow from the filtered group…

However this is not very satisfactory as its not ‘obvious’ and I don’t know if this is by design
or merely a coincidence that it works this way.

It would be nice if the .Visible property actually reflected the reality of whether a row
was visible or not.

thanks again,

Imported from legacy forums. Posted by Rob (had 3612 views)