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

Change color of current cell in DataGridView

$
0
0

I have a dataGridView that has it's 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 doesn't seem to work.


Viewing all articles
Browse latest Browse all 2535

Trending Articles



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