Colour Selected Cell Only

2 posts, 0 answers
  1. Mary
    Mary avatar
    12 posts
    Member since:
    Jul 2014

    Posted 28 Jun Link to this post

    Hi,

     

    I've been trying to figure out how to get my radgridview to colour/put a border around the selected cell only when the user clicks on it. At the moment, using the following code, the grid draws horizontal borders on the selected row when a cell is selected (image attached).

     

        Private Sub gridView_CellFormatting(sender As Object, e As CellFormattingEventArgs) Handles gridView.CellFormatting

            If Not e.CellElement.IsCurrent AndAlso
                e.CellElement.RowInfo.IsCurrent Then
                e.CellElement.BorderColor = Color.FromArgb(208, 215, 229)
            Else
                e.CellElement.ResetValue(LightVisualElement.BorderColorProperty, ValueResetFlags.Local)
            End If

        End Sub

        Private Sub gridView_RowFormatting(sender As Object, e As RowFormattingEventArgs) Handles gridView.RowFormatting

            e.RowElement.DrawFill = False
            e.RowElement.DrawBorder = False

        End Sub

     

    How can I get those lines above and below the row to go away?

    Thanks for your help.

  2. Mary
    Mary avatar
    12 posts
    Member since:
    Jul 2014

    Posted 06 Jul Link to this post

    I set the SelectionMode property to 'CellSelect' to fix this.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top