Check color of the rows of the datagridview c# -
i want check if row contains white color should not replaced in datagridview otherwise if contains other color text in row can replaced don't know how check condition in scenario.
this code.
private void button9_click_1(object sender, eventargs e) { var original = ((datatable)datagridview1.datasource); var clone = original.clone(); var ordinal = original.columns["stringtext"].ordinal; (int = 0; < original.rows.count; i++) { var values = original.rows[i].itemarray; values[ordinal] = ((values[ordinal].tostring()).tolower()) .replace(textbox6.text.tolower(), textbox7.text); clone.rows.add(values); } datagridview1.datasource = clone; string filterby; filterby = "stringtext '%" + textbox7.text + "%'"; ((datatable)datagridview1.datasource).defaultview.rowfilter = filterby; }
any ideas?
to loop through cells in datagridview
, check background color of cell can like
for (int c = 0; c < datagridview.columncount; c++) { (int r = 0; r < datagridview.rowcount; r++) { if (datagridview.defaultcellstyle.backcolor != color.white) // update here } }
i hope helps.
Comments
Post a Comment