c# - Fill DataGridView row according to a string value of a cell -
im trying fill row according string text, better explained:
cell number 7 has 2 values ("1 - pago" or "2- pendente"), if 1 option want row painted in green, else want red.
i tried several codes, cant it, have far:
foreach (datagridviewrow row in datagridview1.rows) if (convert.toint32(row.cells[7].value) == "1- pago)) { row.defaultcellstyle.backcolor = color.red; }
pretty sure, error on 2 line, im new , still couldnt find solution, tried changed value text, still errors.
thank you.
you have 2 major compile errors:
1) tried equal int , string
2) string @ right side of equation doesnt have proper "" symbol @ end.
try this:
foreach (datagridviewrow row in vendorsdatagridview.rows) if (row.cells[7].value.tostring() == "1 - pago") row.defaultcellstyle.backcolor = color.red;
Comments
Post a Comment