Some few thoughts without testing or anything else:
- Cache the value of the cell in a local variable.
- Replace for-loops if possible with foreach-loops Replace for-loops if possible with foreach-loops.
- The call of
boxList[x].Name.ToString()
is unnecessary, it is already a String. break
after setting the visibility to avoid unnecessary checks.
foreach(DataGridViewRow row in dgv.Rows)
{
String cellValue = row.Cells[1].Value.ToString();
foreach(CheckBox boxItem in boxList)
{
if(cellValue == boxItem.Name)
{
row.Visible = false;
break;
}
}
}
On another sidenote, please use meaningful variable names, even in such stupid iterating loops.
Some few thoughts without testing or anything else:
- Cache the value of the cell in a local variable.
- Replace for-loops if possible with foreach-loops.
- The call of
boxList[x].Name.ToString()
is unnecessary, it is already a String. break
after setting the visibility to avoid unnecessary checks.
foreach(DataGridViewRow row in dgv.Rows)
{
String cellValue = row.Cells[1].Value.ToString();
foreach(CheckBox boxItem in boxList)
{
if(cellValue == boxItem.Name)
{
row.Visible = false;
break;
}
}
}
On another sidenote, please use meaningful variable names, even in such stupid iterating loops.
Some few thoughts without testing or anything else:
- Cache the value of the cell in a local variable.
- Replace for-loops if possible with foreach-loops.
- The call of
boxList[x].Name.ToString()
is unnecessary, it is already a String. break
after setting the visibility to avoid unnecessary checks.
foreach(DataGridViewRow row in dgv.Rows)
{
String cellValue = row.Cells[1].Value.ToString();
foreach(CheckBox boxItem in boxList)
{
if(cellValue == boxItem.Name)
{
row.Visible = false;
break;
}
}
}
On another sidenote, please use meaningful variable names, even in such stupid iterating loops.
Some few thoughts without testing or anything else:
- Cache the value of the cell in a local variable.
- Replace for-loops if possible with foreach-loopsReplace for-loops if possible with foreach-loops.
- The call of
boxList[x].Name.ToString()
is unnecessary, it is already a String. break
after setting the visibility to avoid unnecessary checks.
foreach(DataGridViewRow row in dgv.Rows)
{
String cellValue = row.Cells[1].Value.ToString();
foreach(CheckBox boxItem in boxList)
{
if(cellValue == boxItem.Name)
{
row.Visible = false;
break;
}
}
}
On another sidenote, please use meaningful variable names, even in such stupid iterating loops.
Some few thoughts without testing or anything else:
- Cache the value of the cell in a local variable.
- Replace for-loops if possible with foreach-loops.
- The call of
boxList[x].Name.ToString()
is unnecessary, it is already a String.
foreach(DataGridViewRow row in dgv.Rows)
{
String cellValue = row.Cells[1].Value.ToString();
foreach(CheckBox boxItem in boxList)
{
if(cellValue == boxItem.Name)
{
row.Visible = false;
break;
}
}
}
On another sidenote, please use meaningful variable names, even in such stupid iterating loops.
Some few thoughts without testing or anything else:
- Cache the value of the cell in a local variable.
- Replace for-loops if possible with foreach-loops.
- The call of
boxList[x].Name.ToString()
is unnecessary, it is already a String. break
after setting the visibility to avoid unnecessary checks.
foreach(DataGridViewRow row in dgv.Rows)
{
String cellValue = row.Cells[1].Value.ToString();
foreach(CheckBox boxItem in boxList)
{
if(cellValue == boxItem.Name)
{
row.Visible = false;
break;
}
}
}
On another sidenote, please use meaningful variable names, even in such stupid iterating loops.
Some few thoughts without testing or anything else:
- Cache the value of the cell in a local variable.
- Replace for-loops if possible with foreach-loops.
- The call of
boxList[x].Name.ToString()
is unnecessary, it is already a String.
foreach(DataGridViewRow row in dgv.Rows)
{
String cellValue = row.Cells[1].Value.ToString();
foreach(CheckBox boxItem in boxList)
{
if(cellValue == boxItem.Name)
{
row.Visible = false;
break;
}
}
}
On another sidenote, please use meaningful variable names, even in such stupid iterating loops.