After I figured out how to change the different cell’s border colors using the RGB values to generate a random color, I now want to change the background color of each cell as well. This is for DataGridView. Below is my relevant code that allowed me to change cell border colors and now somewhere in that code lies a way to change background color of each cell but I am not familiar with this code since it is from a freeware. Does anyone know what I must change in this code to affect the background color of each cell?
Here is my code:
The solution printing a background color is similar to the pen solution except you need to use a brush, usually a
SolidBrush:Note that since you are drawing text and other graphics on this rectangle, you probably want to paint the background color first, before all the other graphics. (Otherwise, you will end up with only a solid colored rectangle with no text.)