Home Forums WinForms controls Xceed Grid for WinForms Searching and filtering data in Xgreed Cells Reply To: Searching and filtering data in Xgreed Cells

User (Old forums)
Member
Post count: 23064

You just want to retrieve the rows? I thought you wanted to filter the grid, and hide the rows that don’t match.
Here’s a function that returns an ArrayList with the matching rows for a specific text.<code>using System.Collections;
using Xceed.Grid;
using Xceed.Grid.Collections;

private ArrayList MatchingDataRows(GridControl grid, string text)
{
ArrayList matchingRows = new ArrayList();

DataRowList gridRows = grid.DataRows;
int rowCount = gridRows.Count;
int columnCount = grid.Columns.Count;

text = text.ToLower();

for(int i=0; i<rowCount; i++)
{
DataRow row = gridRows[i];
CellList cells = row.Cells;
for(int j=0; j<columnCount; j++)
if (cells[j].GetTextToPaint().ToLower().Contains(text))
{
matchingRows.Add(row);
break;
}
}

return matchingRows;
}</code>

Imported from legacy forums. Posted by Tommy (had 4115 views)