Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42202

DGV draw boarder lines

$
0
0
I am really needi9ng some help with fixing the code i have below.

What its designed for.
this was needed to try draw a rounded rectangle over a DGV row when its selected only.
then paint a gradient brush inside the boarder.

Now all this works great but when the DGV is opened the first row gets the paint but its over the top of the data in the row.
until you click the row then the data comes to the front

Also when you select another row its meant to paint that row instead the paint does not leave the first row


the code
Code:


    Private Sub ItemsdatabaseDataGridView_RowPrePaint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewRowPrePaintEventArgs) Handles ItemsdatabaseDataGridView.RowPrePaint

        If ItemsdatabaseDataGridView.Rows(e.RowIndex).Selected Then


            Dim rect As New Rectangle(3, 2, e.RowBounds.Width - 6, e.RowBounds.Height - 4)
            Dim b As New System.Drawing.Drawing2D.LinearGradientBrush(rect, Color.FromArgb(255, 241, 248, 251), Color.FromArgb(255, 139, 195, 225), Drawing2D.LinearGradientMode.Vertical)
            Dim b2 As New System.Drawing.SolidBrush(Color.FromArgb(255, 41, 153, 255))

            Try

                e.Graphics.FillRectangle(b, rect)
                clsColors.DrawRoundedRectangle(e.Graphics, rect.Left - 1, rect.Top - 1, rect.Width, rect.Height + 1, 4, Color.FromArgb(255, 41, 153, 255))
                clsColors.DrawRoundedRectangle(e.Graphics, rect.Left - 2, rect.Top - 2, rect.Width + 2, rect.Height + 3, 4, Color.White)

            Finally

                b.Dispose()
                b2.Dispose()

            End Try

        End If
    End Sub


Viewing all articles
Browse latest Browse all 42202

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>