Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Column Header Cell in DatagridView shows blue colour background, when the form loads.

$
0
0

Hi, 

 I have a form with one DataGridView, which fills up from the database when the form loads. Everything loads properly the first time. After I make changes, close the form and reopen it, the header cell of the second column turns dark blue, as if selected. Why does this happen? Please see image. I have set the following properties in the design:

ColumnHeaderDeaultCellStyle --> BackColor & SelectionBackColor = Color.Control

EnableHeaderVisualStyles --> True

Inside the gridview.Columns properties table:

DeafultCellStyle --> BackColor and SelectionBackColor --> Color.Control

Just to check, I wrote a message box code in the load form to check the backcolor properties of the errant column: 

MessageBox.Show(dgvGrid.Columns(1).HeaderText & " : " & dgvGrid.Columns(1).HeaderCell.Style.BackColor.ToString & "   " & dgvGrid.Columns(1).Selected.ToString)

This is what the message box shows: Condition: Color [Empty] False

Screenshot:


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>