Change color of current cell in DataGridView

  • Thread starter Thread starter CommanderKeen
  • Start date Start date
C

CommanderKeen

Guest
I have a dataGridView that has its property SelectionMode = FullRowSelect

Even in this mode the current cell property gets set.

When a row is selected the row is highlighted with the row indicator (which is by default blue). I want to change the color of the current cell as a DIFFERENT color than the highlighter color.

I tried to add the code:




dgvTemp.CurrentCellChanged += new EventHandler(dgvTemp_CurrentCellChanged);

void dgvTemp_CurrentCellChanged(object sender, EventArgs e)
{
DataGridView dgvTemp = (DataGridView)sender;
if (dgvTemp.CurrentCell != null)
{
dgvTemp.CurrentCell.Style.BackColor = Color.BlueViolet;
dgvTemp.CurrentCell.Style.ForeColor = Color.BlueViolet;
}
}


But it doesnt seem to work.

Continue reading...
 
Back
Top