When we run our application on Windows 11 the DataGridView control seems to act differently. Hovering over a cell in a DataGridViewComboBoxColumn turns the cell black making any text in that cell unreadable (see image). Windows 10 is OK. Screenshot of datagridview
Any ideas why this control acts differently in Windows 11. And if so, is it permanent? I could add some code in to try and fix this, but so far my efforts (below) have not worked.
private void DataGridView_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex >= 0 && e.RowIndex >= 0 && dataGridView.Columns[e.ColumnIndex] is DataGridViewComboBoxColumn)
{
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.FromArgb(220, 220, 255);
}
}
private void DataGridView_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex >= 0 && e.RowIndex >= 0 && dataGridView.Columns[e.ColumnIndex] is DataGridViewComboBoxColumn)
{
dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = SystemColors.ControlLight;
}
}