I'm reading all the cells in a DataGridView
, but on each of them I want to compare the first 3 elements of the cell as a string, and turn it into a blank cell if they match.
So far I've tried this
for (int z = 0; z < dataGridView7.Rows.Count; z++)
{
for (int i = 0; i < dataGridView7.Columns.Count; i++)
{
string caixa = dataGridView7[z, i].Value.ToString(); //problem right here
string caixaselecta = caixa.Substring(0, 3);
if (caixaselecta == "0 *")
{
dataGridView7[z, i].Value = "";
}
}
}
The for
cycles are correctly done, and the matches too. I think the problem is identifying the current cell being analyzed, and turn it into a string.
I've tried similar ways to reach the current cell, but either I get a error, or the string caixa
isn't correctly defined.
Any hints?