I'm wanting to create an effect where the user knows when they're hovering over a picturebox, but I don't want to use the MouseHover event because with the Hover event you have to wait a bit of time for it to fire, where I need it immediately. What I'm currently doing is setting the BorderStyle in the MouseEnter/Leave events. The issue comes with the MouseLeave event, it doesn't always set the BorderStyle back to none. The way I'm loading the pictureboxes is like so:
The MouseEnter/Leave look like this:Code:For x As Integer = 0 To board_size.Width - 1 For y As Integer = 0 To board_size.Height - 1 Dim pb As New PictureBox With pb .BackColor = Color.White .Location = New Point(x * 50, y * 50) .Size = New Size(50, 50) .SizeMode = PictureBoxSizeMode.Zoom .BorderStyle = BorderStyle.None End With AddHandler pb.MouseEnter, AddressOf board_MouseEnter AddHandler pb.MouseLeave, AddressOf board_MouseLeave board(x, y) = pb SplitContainer1.Panel2.Controls.Add(pb) Next Next
Is there any reason why the borderstyle isn't being set to none?Code:Private Sub board_MouseEnter(sender As Object, e As EventArgs) Dim pb As PictureBox = DirectCast(sender, PictureBox) pb.BorderStyle = BorderStyle.FixedSingle End Sub Private Sub board_MouseLeave(sender As Object, e As EventArgs) Dim pb As PictureBox = DirectCast(sender, PictureBox) pb.BorderStyle = BorderStyle.None End Sub




Reply With Quote
