Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27034

Question about MouseEnter

$
0
0
When the left mouse button is being held down, and the mouse is moved to a seperate control, is the MouseEnter event of that seperate control not fired? Because I have a grid of picturebox's and I'm trying to set the backcolor of the picturebox's I select based on if my mouse is being held down and moving over them like this:
Code:

    Private Sub pb_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)
        clicked = True

        Dim c As PictureBox = DirectCast(sender, PictureBox)
        Select Case style
            Case PenStyle.Regular
                c.BackColor = currentcolor
            Case PenStyle.Eraser
                c.BackColor = transparentColor
        End Select
    End Sub

    Private Sub pb_Enter(ByVal sender As Object, ByVal e As EventArgs)
        Dim c As PictureBox = DirectCast(sender, PictureBox)
        If clicked Then
            Select Case style
                Case PenStyle.Regular
                    c.BackColor = currentcolor
                Case PenStyle.Eraser
                    c.BackColor = transparentColor
            End Select
        End If
    End Sub

    Private Sub pb_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs)
        clicked = False
    End Sub

But when I move my mouse to a different picturebox in the grid, it's backcolor isn't changing.

Viewing all articles
Browse latest Browse all 27034

Trending Articles



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