Here is a solution but will prevent sorting via the column header
someDataGridView.EnableHeadersVisualStyles = false;
someDataGridView.ColumnHeadersDefaultCellStyle.SelectionBackColor =
someDataGridView.ColumnHeadersDefaultCellStyle.BackColor;
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am using Visual Studio 17.5.4 and building a Windows Forms app with a DataGridView as a list of items to select then populate the form fields. All this works but I have a nagging problem to overcome. When you select a row from the grid, it will highlight the column header for whichever cell that was clicked, or if you click the row header panel of the row it will highlight the first column.
I am currently using the SelectionChanged event to capture the selection but have tried CellClick & RowEnter with the same result. Are there any suggestions on how to prevent the column header from changing color?
Here is a solution but will prevent sorting via the column header
someDataGridView.EnableHeadersVisualStyles = false;
someDataGridView.ColumnHeadersDefaultCellStyle.SelectionBackColor =
someDataGridView.ColumnHeadersDefaultCellStyle.BackColor;