I have a DataGridView that I’m feeding a List
The DataGridView is populating perfectly, but I’d like now to be able to search within the grid (any column) for a value the user enters.
I’ve been flailing about trying to sneak my way into a solution, but I can’t find a DataGridView.Cells[X,Y] type of property.
I tried this:
String searchVal = textBoxValueToFindInGrid.Text.Trim();
for (int i = 0; i < dataGridViewPlatypusElements.RowCount; i++)
{
for (int j = 0; j < dataGridViewPlatypusElements.ColumnCount; j++) {
if (dataGridViewPlatypusElements.Text.Contains(searchVal))
{
dataGridViewPlatypusElements.GoTo*(Cells[j,i]);
}
}
}
…but, of course, DataGridView.Text does not contain anything useful. This is where I need the Cells[X,Y] property.
- I would not consider it harmful in this case.
How about