(First time posting, please be gentle.)
I have a DataGridView on my form, that makes the cells in the current row and column appear highlighted. I also added a CellPainting part to give the active cell a thicker border. The code goes like this:
Private Sub DGV_CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs) Handles DGV.CellPainting
Try
Dim CRow As Integer = DGV.CurrentCell.RowIndex
Dim CCol As Integer = DGV.CurrentCell.ColumnIndex
If e.RowIndex = CRow AndAlso e.ColumnIndex = CCol Then
Using BBrush As Brush = New SolidBrush(Color.Black)
Using BPen As Pen = New Pen(BBrush, 2)
Dim CBRect As Rectangle = e.CellBounds
CBRect.Width -= 1
CBRect.Height -= 1
CBRect.X = rectDimensions.Left
CBRect.Y = rectDimensions.Top
e.Graphics.DrawRectangle(BPen, CBRect)
e.Handled = True
End Using
End Using
End If
Catch
End Try
End Sub
The above works fine in the sense it adds the border to the cell, however the active cell does not show up as highlighted, just white. I do not understand as there is no specification of FillRectangle() or of any other colours than the black border, so I assumed it would keep the cell colour the same, but it does not go blue like the other cells in its row and column.
Any help would be greatly appreciated :)