按钮可见继电器

时间:2016-09-28 17:18:38

标签: vb.net

嗨,你可以帮我看看如何将6个按钮放入一个vb格式但是1个私有子或任何你需要的东西,并让它隐藏并在你移动鼠标时互相显示它可能吗?例如,当我将鼠标指向按钮1时,按钮2出现,然后当我指向按钮2时出现第3个按钮,依此类推其他按钮

我是vb.net的新人     公共类Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.MouseMove,
    Button2.MouseMove, Button3.MouseMove, Button4.MouseMove, Button5.MouseMove, Button6.MouseMove

        Button1.Hide()
        Button2.Show()
        Button2.Hide()
        Button3.Show()
        Button3.Hide()
        Button4.Show()
        Button4.Hide()
        Button5.Show()
        Button5.Hide()
        Button6.Show()
        Button6.Hide()
        Button1.Show()


    End Sub
End Class

1 个答案:

答案 0 :(得分:-1)

以表格加载

 Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Button1.Show()
        Button2.Hide()
        Button3.Hide()
        Button4.Hide()
        Button5.Hide()
        Button6.Hide()
    End Sub

然后在所有按钮的一个函数调用中处理按钮鼠标移动事件,如下所示。并编写逻辑如下所示。

我为3个按钮写了它。你可以安排休息。

在代码下方滚动左侧,查看所有处理的按钮鼠标移动事件。

Private Sub Button_MouseMove(sender As Object, e As    System.Windows.Forms.MouseEventArgs) Handles Button1.MouseMove, Button2.MouseMove, Button3.MouseMove, Button4.MouseMove, Button5.MouseMove, Button6.MouseMove
        If (Button1.Visible) Then
            Button1.Hide()
            Button2.Show()
            Exit Sub
        End If

        If (Button2.Visible) Then
            Button2.Hide()
            Button3.Show()
            Exit Sub
        End If
    End Sub