2

How to not having the header of the first column selected in a datagridview considering that the SelectionMode must be set to FullRowSelected .

I tried EnableHeadersVisualStyles to false but it didn't work.

enter image description here

8oris
  • 320
  • 2
  • 12
  • This [link](https://stackoverflow.com/questions/54234094/disable-datagridview-rowheader-and-columnheader-from-being-selected-and-click) may help – mcutrin Sep 30 '21 at 10:29
  • Unfortunately, it does not. :( – 8oris Sep 30 '21 at 12:15
  • Add in app.config: `` -- See also: [What's new in accessibility in .NET Framework](https://learn.microsoft.com/en-us/dotnet/framework/whats-new/whats-new-in-accessibility#whats-new-in-accessibility-in-the-net-framework-472) – Jimi Sep 30 '21 at 18:19

1 Answers1

2

Have you considered simply changing the grid's headers SelectionBackColor to the default “Control” color… something like…

dataGridView1.ColumnHeadersDefaultCellStyle.SelectionBackColor = Color.FromKnownColor(KnownColor.Control);
JohnG
  • 9,259
  • 2
  • 20
  • 29
  • 1
    That's right. Combined with `DataGridView1.EnableHeadersVisualStyles = False`, which it appears that OP uses already, `DataGridView1.ColumnHeadersDefaultCellStyle.SelectionBackColor = Color.FromKnownColor(KnownColor.Control)` should work. – djv Sep 30 '21 at 18:14
  • `DataGridView1.ColumnHeadersDefaultCellStyle.SelectionBackColor` was the property i was looking for. Perfect, it's exactly that and it works perfectly. Thanks a lot! – 8oris Oct 01 '21 at 07:44