Derek W
Derek W

Reputation: 10026

DataGridView Selected Cell Default Color

Does anyone know the RGB code of DataGridView's selected cell background color. I'm currently trying to make certain cells appear to be blank until a certain condition is satisfied. Handling the 'unselected' ForeColor was easy as all it required was Color.White. But handling the SelectionForeColor has not been the easiest. The closest default color that I have found is Color.DodgerBlue.

I've referenced this site, but it appears that I am out of luck when it comes to a provided color.

Below is the color that I am referring to.

enter image description here

I feel that there must be a way to access this property? But how? Thanks in advance for any help!

Upvotes: 8

Views: 22672

Answers (2)

Derek W
Derek W

Reputation: 10026

The color that I was looking for was: SystemColors.Highlight.

If you go to the Properties section of your DataGridView object. There is a property called DefaultCellStyle and under that there is a section called Appearance where the SelectionBackColor property resides. The default for SelectionBackColor is Highlight which is under System.Drawing.SystemColors.

Upvotes: 17

lc.
lc.

Reputation: 116528

One property to try is DataGridView.RowsDefaultCellStyle.SelectionBackColor, although you may be more interested in DataGridViewCell.InheritedStyle.SelectionBackColor.

Upvotes: 3

Related Questions