Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

conditional change of a datagridviews cell background color and text

This is for a winform vb.net 2008 app. I'm bringing data back from a database and based on some static conditions... i want to change the color of the background and the text. There is no rowdatabound event in winform...

hope someone can provide some guidance thanks shannon

like image 970
jvcoach23 Avatar asked Oct 28 '09 19:10

jvcoach23


2 Answers

I got it working... in the RowPostPaint event.. If I put in

if (my criteria here)
    Me.dgTableInfo.Rows(e.RowIndex).Cells("ColumnName").Style.BackColor = Color.Red
end if
like image 132
jvcoach23 Avatar answered Sep 28 '22 04:09

jvcoach23


Don't forget to set the selectoinBackColor too... otherwise if your red row changes, but you have it highlighted, it will look just like all the rest anyway.

like image 21
Jrud Avatar answered Sep 28 '22 02:09

Jrud