Skip to main content
Code Review

Return to Revisions

3 of 3
replaced http://stackoverflow.com/ with https://stackoverflow.com/

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.

Bobby
  • 8.2k
  • 2
  • 35
  • 43
default

AltStyle によって変換されたページ (->オリジナル) /