避免使用mouseHover和mouseLeave将按钮放在同一个列表框中

时间:2018-02-15 05:56:53

标签: vb.net button listbox mouseleave mousehover

我试图显示放置在列表框上的按钮(类似于acrobat reader工具箱):当用户在ListBox中移动鼠标时,按钮出现,并且当用户离开ListBox区域时它们必须隐藏。问题是:当我将鼠标移到列表框上时,按钮出现但当我尝试点击它时,程序会将此移动检测为ListBox_MouseLeave并隐藏按钮!...这就是逻辑(鼠标现在是在按钮上)但是......

Private Sub ListBox3_MouseHover(sender As Object, e As MouseEventArgs) Handles ListBox3.MouseHover
    Button6.Visible = True
End Sub

Private Sub ListBox3_MouseLeave(sender As Object, e As EventArgs) Handles ListBox3.MouseLeave
    Button6.Visible = False
End Sub

如何避免使用mouse_leave指令并让按钮可见?

1 个答案:

答案 0 :(得分:1)

将隐藏代码移至表格鼠标悬停。

Private Sub Form4_MouseHover(sender As Object, e As EventArgs) Handles Me.MouseHover
        Button1.Visible = False
    End Sub

    Private Sub ListBox1_MouseEnter(sender As Object, e As EventArgs) Handles ListBox1.MouseEnter
        Button1.Visible = True
    End Sub