使用VS 2012创建一个包含三个图片框的新表单。这段代码旨在在鼠标进入图片框时绘制边框,并在鼠标离开时删除它。但结果不一致。有时会绘制/删除边框,有时不会。这段代码并不复杂。
Private Sub PictureBox_MouseEnter(sender As Object, e As EventArgs) _
Handles PictureBox1.MouseEnter, PictureBox2.MouseEnter, PictureBox3.MouseEnter
Dim pb As PictureBox = DirectCast(sender, PictureBox)
pb.BorderStyle = BorderStyle.FixedSingle
' Debug.WriteLine("E " & pb.Name)
End Sub
Private Sub PictureBox_MouseLeave(sender As Object, e As EventArgs) _
Handles PictureBox1.MouseLeave, PictureBox2.MouseLeave, PictureBox3.MouseLeave
Dim pb As PictureBox = DirectCast(sender, PictureBox)
pb.BorderStyle = BorderStyle.None
' Debug.WriteLine("X " & pb.Name)
End Sub
PictureBox
控件里面有子控件吗? - EkoostikMartin