none
[DataGridView - C# - .Net 2.0] Change Selected Cell Color in FullRowSelect SelectionMode RRS feed

  • Question

  • Hello,

     

    I would like to know if someone has a way to change the backcolor of the selected Cell if the DataGridView.SelectionMode is set to FullRowSelect, I would like the user to see the current cell (not the dotted frame) when he navigate with the tabulation.

     

    Thx for your help.

    Barzot

    Wednesday, June 27, 2007 2:05 PM

Answers

  •  

    Hi Barzot,

     

    We can handle the DataGridView.CellPaint event and the handler may be something like this:

    Code Snippet

            void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)

            {

                if(e.RowIndex == this.dataGridView1.CurrentCell.RowIndex && e.ColumnIndex == this.dataGridView1.CurrentCell.ColumnIndex)

                {

                    e.CellStyle.SelectionBackColor = Color.Red;

                }

            }

     

    Hope this helps.

    Regards

    Friday, June 29, 2007 7:27 AM

All replies

  •  

    Hi Barzot,

     

    We can handle the DataGridView.CellPaint event and the handler may be something like this:

    Code Snippet

            void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)

            {

                if(e.RowIndex == this.dataGridView1.CurrentCell.RowIndex && e.ColumnIndex == this.dataGridView1.CurrentCell.ColumnIndex)

                {

                    e.CellStyle.SelectionBackColor = Color.Red;

                }

            }

     

    Hope this helps.

    Regards

    Friday, June 29, 2007 7:27 AM
  • Thx, for your reply,

    I'll give a try, and respond asap.

     

    Barzot

    Monday, July 2, 2007 6:15 AM