BlueMystical / Dark-Mode-Forms

Apply Dark Mode to all Controls in a Form [WinForms]
GNU General Public License v3.0
111 stars 15 forks source link

[DataGridView] Blue background for selected row and 1st column with Version 1.8.1 #39

Closed MagicAndre1981 closed 3 months ago

MagicAndre1981 commented 3 months ago

I've updated the source files to 1.8.1 and now I see this blue background for (only) the 1 column header and the selected row with DataGridView component:

image

BlueMystical commented 3 months ago

thanks for the report, i'll look into it.

BlueMystical commented 3 months ago

hi, this should be fixed on v1.8.3 Thanks.

MagicAndre1981 commented 3 months ago

hi, this should be fixed on v1.8.3

no I still see it. I see you changed the code to if control again so this is the new version. Please add a version comment on top or create a nuget

BlueMystical commented 3 months ago

the DataGridView on the Example Form shows the Blue highlight only on the selected Cell, please provide more details on how you implemented your Grid so i can replicate the issue.

image

MagicAndre1981 commented 3 months ago

I set the source and select a cell (Cell[0] is an ID from the database table which I hide):

dataGridView.AutoGenerateColumns = true;
dataGridView.DataSource = list;

if (dataGridView.Rows.Count > 0)
{
    dataGridView.CurrentCell = dataGridView.Rows[0].Cells[1];
}
BlueMystical commented 3 months ago

Using almost identical code: image You can check the code here: https://github.com/BlueMystical/Dark-Mode-Forms/blob/f14d8e13a50c54a38a1e19eb3923b68105e5a667/Form1.cs#L64

How about the Grid's Selection Mode? image

MagicAndre1981 commented 3 months ago

you set a dataGridViewCellStyle

dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.Red;
dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;

and assign this (dataGridView1.ColumnHeadersDefaultCellStyle) what I don't do.

My SelectionMode is System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; ColumnHeadersHeightSizeMode is AutoSize for my code and yours.

BlueMystical commented 3 months ago

mmm... that was all autogenerated code from VS, i simply drop a Grid and leave all its props at their default. if i make to assign, intentionally this time, the ColumnHeadersDefaultCellStyle that will fix your issue? i mean it wont be a big deal for me to directly assign that.

MagicAndre1981 commented 3 months ago

if i make to assign, intentionally this time, the ColumnHeadersDefaultCellStyle that will fix your issue?

no, it is SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; Adding this to your sample also shows the blue background.

BlueMystical commented 3 months ago

yeah, when the SelectionMode is FullRow, the headers get selected:

image

There is nothing on my code to make that to happen, its the Grids natural behaviour, but let me see what can i do to beautify it.

MagicAndre1981 commented 3 months ago

before 1.8.1 I didn't see this color. This is why I was confused.

BlueMystical commented 3 months ago

once i understood the reason of the issue the fix was quite easy, its alive on v1.8.4

image

Thank you for reporting this and for your patience. Regards.