Search in dataGrid

May 10, 2014 at 11:14 AM
Hello,
how to search in dataGrid after filtering?
Coordinator
May 15, 2014 at 12:19 PM
SourceGrid does not provide search functionality out of the box. This greatly varies where you are loading data from - you can do a search in datasource, or just by looping through each cell.
May 22, 2014 at 10:10 AM
How to make a loop through each cell in C# ?
May 23, 2014 at 7:40 AM
Edited May 23, 2014 at 7:47 AM
see next
May 23, 2014 at 7:47 AM
Edited May 23, 2014 at 8:00 AM
formatting scrambles my answer, so I avoid using leading spaces...
and read '&#43 ;' as a plus sign (even in a codeblock it uses HTML codes!)

Something like

for (int col = 0; col == grid.ColumnsCount; col++)
{
for (int row = 0; row == grid.RowsCount; row++)
{
// .Value is an object, eventually use .Value.ToString() for casting to string
if (grid[row, col].Value == anyValueYouAreLookingFor)
{
doSomething();
// if needed quit here by uncommenting next line
//break;
}
}
}

If you have fixed rows or columns, and want to avoid searching in it, change the 0 to 1 (like int col = 1).
I've no idea if searching with Linq is also possible....

Enjoy coding,

Pieter