1 Attachment(s)
How do I make the BG color of my DataGridView WHITE?
This sound a bit silly, but how do I make the BG color of my DataGridView WHITE?
Right now they are Grey.
I tried changing DataGridView Properties, BackgroundColor and GridColor to WHITE, but still doesn't work
Can this be done without coding?
Attachment 167955
Re: How do I make the BG color of my DataGridView WHITE?
It's a nested property you need. The DefaultCellStyle property of the grid is type DataGridViewCellStyle. That class is used in various places to set various style-related properties of cells and, in this case, it is the default style for every cell in the grid. The BackColor property of that type determines the BackColor of affected cells. In this case, it's set to SystemColors.Window by default so, if you're seeing grey, either you must have already set the property or else your system theme uses grey for windows. You can change it in the designer via the properties window and a dialogue, or you can change it in code. If you do it in code, I think that it will only affect cells created after the change.
Re: How do I make the BG color of my DataGridView WHITE?
Quote:
Originally Posted by
jmcilhinney
It's a nested property you need. The DefaultCellStyle property of the grid is type DataGridViewCellStyle. That class is used in various places to set various style-related properties of cells and, in this case, it is the default style for every cell in the grid. The BackColor property of that type determines the BackColor of affected cells. In this case, it's set to SystemColors.Window by default so, if you're seeing grey, either you must have already set the property or else your system theme uses grey for windows. You can change it in the designer via the properties window and a dialogue, or you can change it in code. If you do it in code, I think that it will only affect cells created after the change.
Ok, so if I understand correctly, you are saying the color is inherited?
And I need to go to the SystemColors.Window to change?
Can I just do this in the VB editor?
If really need to code, I guess it's fine.
Re: How do I make the BG color of my DataGridView WHITE?
Quote:
Originally Posted by
Volkof
Ok, so if I understand correctly, you are saying the color is inherited?
And I need to go to the SystemColors.Window to change?
Apparently you don't understand. Maybe start by actually looking at the value of the property I told you was responsible for that colour. If that is indeed set to SystemColors.Window then it is the default value and the actual colour is coming from your system theme. If you want to change the system theme then that's done via the system, so nothing to do with VB or VS. If you want to change the property value to something other than what it is currently, go ahead and change it.
Re: How do I make the BG color of my DataGridView WHITE?
It's ok, I found the issue.
I have this and commented it out:
Code:
Private Sub ProjectsDataGridView_CellFormatting(sender As System.Object, e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles ProjectsDataGridView.CellFormatting
Re: How do I make the BG color of my DataGridView WHITE?
As I mentioned, the DataGridViewCellStyle class is used in various places. The DefaultCellStyle property is the top level and it can be overridden at various other levels, including the column, row and cell. In the CellFormatting event handler, the e.CellStyle property is, yet again, type DataGridViewCellStyle and is close to the last level at which you can change the style for a cell, i.e. as it is being formatted for rendering. You can still override that style when it gets rendered too.