Disable Cell Highlighting in a datagridview

Ramji picture Ramji · Nov 16, 2009 · Viewed 86.6k times · Source

How to disable Cell Highlighting in a datagridview, Highlighting should not happen even if I click on the cell.

Any thoughts please

Answer

Derek H picture Derek H · Jan 22, 2011

The ForeColor/BackColor kludge wasn't working for me, because I had cells of different colors. So for anyone in the same spot, I found a solution more akin to actually disabling the ability.

Set the SelectionChanged event to call a method that runs ClearSelection

private void datagridview_SelectionChanged(object sender, EventArgs e)
{
    this.datagridview.ClearSelection();
}