vb.net - Binding datagridview font color in datatable c# -
so right have set datatable , binded datagridview.
what program saves realtime log datatable. need have font color in each row based on log level save font color @ each row in data table (6th array of datatable)
is there solution bind style datatable , datagridview?
i using filter search need able backup color once had before color implented.
currently doing. biggest problem after filter has been implemented, style property gone , becomes again no colored colum (all black again)
if (value.contains("<notice>:")) { datagridview1.rows[rownumber].defaultcellstyle.forecolor = color.forestgreen; logparserview.rows[rownumber][6] = "forestgreen"; } else if (value.contains("<debug>:")) { datagridview1.rows[rownumber].defaultcellstyle.forecolor = color.orange; logparserview.rows[rownumber][6] = "orange"; } else if (value.contains("<info>:")) { datagridview1.rows[rownumber].defaultcellstyle.forecolor = color.orange; logparserview.rows[rownumber][6] = "orange"; } else if (value.contains("<warning>:")) { datagridview1.rows[rownumber].defaultcellstyle.forecolor = color.orange; logparserview.rows[rownumber][6] = "orange"; } else if (value.contains("<error>:")) { datagridview1.rows[rownumber].defaultcellstyle.forecolor = color.darkred; logparserview.rows[rownumber][6] = "darkred"; } else if (value.contains("<critical>:")) { datagridview1.rows[rownumber].defaultcellstyle.forecolor = color.darkred; logparserview.rows[rownumber][6] = "darkred"; } else if (value.contains("<alert>:")) { datagridview1.rows[rownumber].defaultcellstyle.forecolor = color.darkred; logparserview.rows[rownumber][6] = "darkred"; } else if (value.contains("<emergency>:")) { datagridview1.rows[rownumber].defaultcellstyle.forecolor = color.indianred; logparserview.rows[rownumber][6] = "indianred"; }
thanks
if understand correctly, need handle datagridview.cellformatting
event, , in handler, set cellstyle
of datagridviewcellformattingeventargs
handler argument.
cheers
edit:
private void datagridview1_cellformatting(object sender, datagridviewcellformattingeventargs e) { if (e.value == someothervalue) e.cellstyle.backcolor = color.red; }
Comments
Post a Comment