I need to change the color of the Header Cell and first column called "col_row" when one or more cells are selected with the mouse like this:
I use this code and its working:
Private Sub gdv_PatioAcopio_CellStateChanged(sender As Object, e As DataGridViewCellStateChangedEventArgs) Handles gdv_PatioAcopio.CellStateChanged
If e.Cell.ColumnIndex = 0 Then
e.Cell.Selected = False
Else
If e.Cell.Selected = True Then
Me.gdv_PatioAcopio.Columns(e.Cell.ColumnIndex).HeaderCell.Style.BackColor = Color.LightBlue
Me.gdv_PatioAcopio.Rows(e.Cell.RowIndex).Cells("col_row").Style.BackColor = Color.LightBlue
ElseIf e.Cell.Selected = False Then
Me.gdv_PatioAcopio.Columns(e.Cell.ColumnIndex).HeaderCell.Style.BackColor = Color.Navy
Me.gdv_PatioAcopio.Rows(e.Cell.RowIndex).Cells("col_row").Style.BackColor = Color.Navy
End If
End If
End Sub
but when i deselect, for example, the third column, the first column changes its color to Color.Navy.
How can i prevent this?
Thanks!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire