Change Color In A Selected Cell In VB.NET Gridview


Hi

I have A Gridview Named MyGrid and I have located A cell  in Row 5 and Column 4 say. I need to change the BackGround color of this cell to a color of my choice. Any Idea how I can do this please.

Many thanks
NolancAsked:
Who is Participating?
 
Meir RivkinFull stack Software EngineerCommented:
Example:

MyGrid.Item(ColumnIndex, RowIndex).Style.BackColor = Color.Red
0
 
nepaluzCommented:
set the selection color in the CellEnter event

    Private Sub MyGrid_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles MyGrid.CellEnter
        MyGrid.Item(e.ColumnIndex, e.RowIndex).Style.SelectionBackColor = Color.Red
    End Sub

Open in new window

0
 
NolancAuthor Commented:
Hi sedgwick

You deserve the 100 points. Thank you for your prompt reply.

Regards
Nolanc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.